garbage collector

Terry Reedy tjreedy at home.com
Thu Jul 26 13:20:26 EDT 2001


"franck delarue" <frdelarue2000 at yahoo.fr> wrote in message
news:mailman.996157859.3533.python-list at python.org...
> hi,
> I use python1 with a lot of object (dictionnairies +
> lists) and my program takes 3 or 4 hours to execute on
> a 4 processors (700 mghz) and 2 Go Ram machine (linux
> red hat).
> The problem is that when the program is finished,
> python still continues to delete the objects (I've put
> some "print" to see when the "del" function is
> executed) during about 30 minutes.
> Is that normal ? Is there a solution to stop the
> program correctly ? ("ctrl+alt+del" or "kill -9 XXX"
> works but i don't feel satisfied)

A Python program stops processing statements and starts the somewhat
undocumented and probably system-dependent cleanup phase (prior to
shutting down completely) when it reaches the end of the main file,
you call sys.exit(), or an exception is uncaught.  Is it this phase
(often < 1` sec) that is taking 30 minutes?  If so, I would think the
hard disk must be thrashing  a lot (is it?) in response to
instructions in __del__ methods (do you have the source so you can
change them?)  Or is the OS thrashing because there are gigabytes of
virtual mem paged out to disk?

Killing the program externally aborts without cleanup, I presume.
When you say that this 'works', you are saying that you do not really
want whatever is done in the 30 minutes to be done.  If the useless
work is something you asked for, stop.  Or maybe you need to more
aggressively delete no-longer needed objects during the multi-hour
execution either by removing unneeded references (perhaps stuck in
lists of objects) or by calling the circular-garbage collector.

Terry J. Reedy






More information about the Python-list mailing list