WojciechMula / pyahocorasick

Python module (C extension and plain python) implementing Aho-Corasick algorithm
BSD 3-Clause "New" or "Revised" License
927 stars 122 forks source link

memory leak for python2 #117

Closed wangye360 closed 1 year ago

wangye360 commented 4 years ago

demo code:


import os import psutil import ahocorasick

def build_automaton(): automation = ahocorasick.Automaton() for i in range(2000000): automation.exists(str(i))

def show_used_memory(): print('memory used: {} M'.format(psutil.Process(os.getpid()).memory_info().rss / (1024. ** 2)))

if name == 'main': build_automaton() show_used_memory()

build_automaton()
show_used_memory()

build_automaton()
show_used_memory()

for python2, result: memory used: 162.6875 M memory used: 255.78125 M memory used: 348.8828125 M

for python3, result: memory used: 10.23046875 M memory used: 10.26171875 M memory used: 10.26171875 M

thanks!

WojciechMula commented 4 years ago

Thank you for the report.

eddy-avanan commented 4 years ago

any plans to fix this?

stemon commented 4 years ago

i have the same problem.

WojciechMula commented 4 years ago

@eddy-avanan Not at that moment, but I'll try to look at this issue. It seems to be a regression, as we already had similar problem and it was solved.

galanamanj commented 2 years ago

Any updates on memory leak issue for python 2?

pombredanne commented 2 years ago

@galanamanj could you try to run the tests listed in the release-checklist.txt file on your Python 2 installation? In particular the valgrind tests.

Actual help to track (and fix) these would be mucho welcomed!

pombredanne commented 1 year ago

I am closing for lack of activity. Please reopen if you feel strongly about it, though Python 2 really fell out of fashion these days ;)