Disabling garbage colletion?

Neil Schemenauer nas at python.ca
Sat May 18 17:44:12 EDT 2002


Philip Swartzleonard wrote:
> Hm, i just read in another post that you can turn off the garbage 
> collector?

import gc
gc.disable()

> What exactly does this stop from happening?

Cyclic garbage structures will not be deallocated (i.e. only reference
counting will be used).

> Is this a good idea if e.g. you have a system which is guarenteed not
> to have cyclic-y problems? Hm..... =)

Sure, although as Aahz noted, the GC is usually not very expensive.  You
could also disable it and call it explicitly when you think it's
necessary (i.e. gc.collect()).

  Neil





More information about the Python-list mailing list