WojciechMula / pyahocorasick

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

Method to manually destroy automaton? #66

Closed ayaanhossain closed 6 years ago

ayaanhossain commented 7 years ago

Hi,

Is there a method I can call or a way to manually ensure the Automaton is destroyed? In my case I am repeatedly creating an Automaton assigned to the same variable and searching based on it, but memory seem to accumulate, which should not be the case if the previous Automaton was automatically garbage collected. Is there a way I could perhaps trigger the garbage collection?

Thanks, Ayaan

WojciechMula commented 7 years ago

You should use gc module (https://docs.python.org/3/library/gc.html). Invoke gc.collect() to force garbage collection.