ActiveState Code

Recipe 457662: Reduce memory usage of "re" module


My company wrote an application server that works as a long running service. We were confronted with a memory usage that we couldn't explain until we found out, that the re module is caching a lot of data in the background.

Python
1
re.purge()

Discussion

The function re.purge() empties the internal cache of the re module. This will help to get some memory back in long running processes ;-)

Comments

  1. 1. At 1:53 p.m. on 27 nov 2005, Nikos Kouremenos said:

    nice! sre docs suck, thanks for this one :)

Sign in to comment