garbage collector

Delaney, Timothy tdelaney at
Fri Jul 27 02:00:57 CEST 2001

> From: franck delarue [mailto:frdelarue2000 at]
> Sent: Friday, 27 July 2001 12:30 AM
> To: Python-list at
> Subject: garbage collector
> 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) 

Sounds to me that

a) You're keeping all your data in memory, leading to massive memory use and
lots of deallocations at program end

b) You're probably thrashing the hard drive (virtual memory)

(b) Would lead to both excessive runtimes and excessive collection times. Is
it really vital that you keep all you data in memory at one time? Can't you
re-use object instances, or at least allow them to be deleted when no longer
needed? Two things could help here - don't hold everything in global
(module-level) dictionaries, and use the del keyword when you know you are
finished with a reference.

Tim Delaney

More information about the Python-list mailing list