Python @ DjangoSpin

Python: Taking Garbage Collection into your own hands

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Garbage Collection in Python

Garbage Collection in Python

Garbage Collection refers to deleting objects from memory when they are no longer needed. Python implements this process using reference counts and reference cycles, and it is automatic, meaning that you don't have to worry about deleting no-longer needed objects yourself. However, Python provides an interface to its garbage collector via its standard library module called gc. This module provides, among other utilities, two functions to enable and disable the collector manually.

>>> import gc
>>> help(gc.enable)
Help on built-in function enable in module gc:

enable(...)
    enable() -> None
    
    Enable automatic garbage collection.

>>> help(gc.disable)
Help on built-in function disable in module gc:

disable(...)
    disable() -> None
    
    Disable automatic garbage collection.

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply