Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Memory leak with Series.str.contains #44981

Closed
2 of 3 tasks
danr opened this issue Dec 20, 2021 · 1 comment
Closed
2 of 3 tasks

BUG: Memory leak with Series.str.contains #44981

danr opened this issue Dec 20, 2021 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@danr
Copy link

danr commented Dec 20, 2021

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

import pandas as pd
import os
import subprocess

df = pd.DataFrame(data={
    'col': ['x'] * 1000
})
while True:
    df = df[df.col.str.contains('x')]
    cmd = f'ps --no-headers -e -o rss -q {os.getpid()}'.split()
    rss = int(subprocess.check_output(cmd))
    print(f'{rss = }')

Issue Description

The resident set size (rss) keeps growing with this example which uses Series.str.contains even though memory should be constant.

Expected Behavior

The memory should be constant.

Installed Versions

$ python3.10 -c 'import pandas; pandas.show_versions()'

INSTALLED VERSIONS
------------------
commit           : 66e3805b8cabe977f40c05259cc3fcf7ead5687d
python           : 3.10.0.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.15.6-arch2-1
Version          : #1 SMP PREEMPT Thu, 02 Dec 2021 15:47:09 +0000
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8
$ python3.10 -c 'import pandas; pandas.show_versions()'

INSTALLED VERSIONS
------------------
commit           : 66e3805b8cabe977f40c05259cc3fcf7ead5687d
python           : 3.10.0.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.15.6-arch2-1
Version          : #1 SMP PREEMPT Thu, 02 Dec 2021 15:47:09 +0000
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 1.3.5
numpy            : 1.21.3
pytz             : 2021.3
dateutil         : 2.8.2
pip              : 21.3.1
setuptools       : 57.4.0
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 3.0.2
IPython          : None
pandas_datareader: None
bs4              : None
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : 3.4.3
numexpr          : 2.7.3
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pyxlsb           : None
s3fs             : None
scipy            : 1.7.3
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
xlwt             : None
numba            : None
@danr danr added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 20, 2021
@jreback
Copy link
Contributor

jreback commented Dec 20, 2021

see #2659

@jreback jreback added this to the No action milestone Dec 20, 2021
@jreback jreback closed this as completed Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants