how do I get modules to stop eating memory

Charles Harrison speedy911 at mindspring.com
Mon Jul 2 10:26:40 EDT 2001


I posted a message about a week ago asking about deleting modules from
memory.  I got several replies with things that should work, but they
didn't.  Here's the scenario that I've been trying:

- open the python shell and import sys and any other module

Python 1.5.2 (#1, Aug 25 2000, 09:33:37)  [GCC 2.96 20000731
(experimental)] on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> import BaseHTTPServer

- I also run 'top' when im doing this to monitor the memory that
python is using. The 2112 is the memory used after importing the 2
modules.

22738 charriso   0   0  2112 2112  1380 S     0.0  1.6   0:00 python

- Now I do what should unload the module 'BaseHTTPServer' and free the
memory.

>>> del BaseHTTPServer
>>> del sys.modules['BaseHTTPServer']

- And now top says that the memory usage is now 2120.  

22738 charriso   0   0  2120 2120  1384 S     0.0  1.6   0:00 python

- Prior to importing BaseHTTPServer the memory usage was 1432. 
Shouldn't Python's memory usage have gone down to that number, or at
least down some?



More information about the Python-list mailing list