Garbage Collection

Michael Hudson mwh21 at cam.ac.uk
Mon Jan 15 05:39:34 EST 2001


"Jens Vogelgesang" <jens.vogelgesang at de.bosch.com> writes:

> 1) How can I free used memory.
>     myHash = {}, del(myHash}

myHash.clear() will empty the dict.  The only way to get the dict to
be collected is to remove all references to it.  This may happen
anyway, or it maybe almost impossible to achieve, depending.

> 2) Can I force a Garbage Collection??

import gc
gc.collect()

... but I suspect that your problem is more likely to stuff not being
garbage when you think it should.

More details?

Cheers,
M.

-- 
  This is an off-the-top-of-the-head-and-not-quite-sober suggestion,
  so is probably technically laughable.  I'll see how embarassed I
  feel tomorrow morning.            -- Patrick Gosling, ucam.comp.misc



More information about the Python-list mailing list