Garbage collection (was: how to "free" an object/var ?)

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Jan 30 19:10:46 EST 2007


Stef Mientki <S.Mientki-nospam at mailbox.kun.nl> writes:

> If I create a large array of data or class, how do I destroy it
> (when not needed anymore) ?

Python comes with garbage collection, which is enabled by default.
Some time after your code stops needing the object, the garbage
collector will clean it up.

To check whether your Python has garbage collection enabled, you can
use the 'gc' interface module:

    Python 2.4.4 (#2, Jan 13 2007, 17:50:26)
    [...]
    >>> import gc
    >>> gc.isenabled()
    True
    >>> help(gc)

This module is only needed if you want to *interact* with the garbage
collector, which you won't unless you want to tune it or turn it off.

-- 
 \          "Immorality: The morality of those who are having a better |
  `\                                       time."  -- Henry L. Mencken |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list