gc - pydoc - phpman

Look up a command

 

Markdown Format | JSON API | MCP Server Tool


gc
NAME MODULE REFERENCE DESCRIPTION FUNCTIONS DATA FILE
Help on built-in module gc:

NAME
    gc - This module provides access to the garbage collector for reference cycles.

MODULE REFERENCE
    https://docs.python.org/3.10/library/gc.html

    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

DESCRIPTION
    enable() -- Enable automatic garbage collection.
    disable() -- Disable automatic garbage collection.
    isenabled() -- Returns true if automatic collection is enabled.
    collect() -- Do a full collection right now.
    get_count() -- Return the current collection counts.
    get_stats() -- Return list of dictionaries containing per-generation stats.
    set_debug() -- Set debugging flags.
    get_debug() -- Get debugging flags.
    set_threshold() -- Set the collection thresholds.
    get_threshold() -- Return the current the collection thresholds.
    get_objects() -- Return a list of all objects tracked by the collector.
    is_tracked() -- Returns true if a given object is tracked.
    is_finalized() -- Returns true if a given object has been already finalized.
    get_referrers() -- Return the list of objects that refer to an object.
    get_referents() -- Return the list of objects that an object refers to.
    freeze() -- Freeze all tracked objects and ignore them for future collections.
    unfreeze() -- Unfreeze all objects in the permanent generation.
    get_freeze_count() -- Return the number of objects in the permanent generation.

FUNCTIONS
    collect(generation=2)
        Run the garbage collector.

        With no arguments, run a full collection.  The optional argument
        may be an integer specifying which generation to collect.  A ValueError
        is raised if the generation number is invalid.

        The number of unreachable objects is returned.

    disable()
        Disable automatic garbage collection.

    enable()
        Enable automatic garbage collection.

    freeze()
        Freeze all current tracked objects and ignore them for future collections.

        This can be used before a POSIX fork() call to make the gc copy-on-write friendly.
        Note: collection before a POSIX fork() call may free pages for future allocation
        which can cause copy-on-write.

    get_count()
        Return a three-tuple of the current collection counts.

    get_debug()
        Get the garbage collection debugging flags.

    get_freeze_count()
        Return the number of objects in the permanent generation.

    get_objects(generation=None)
        Return a list of objects tracked by the collector (excluding the list returned).

          generation
            Generation to extract the objects from.

        If generation is not None, return only the objects tracked by the collector
        that are in that generation.

    get_referents(...)
        get_referents(*objs) -> list
        Return the list of objects that are directly referred to by objs.

    get_referrers(...)
        get_referrers(*objs) -> list
        Return the list of objects that directly refer to any of objs.

    get_stats()
        Return a list of dictionaries containing per-generation statistics.

    get_threshold()
        Return the current collection thresholds.

    is_finalized(obj, /)
        Returns true if the object has been already finalized by the GC.

    is_tracked(obj, /)
        Returns true if the object is tracked by the garbage collector.

        Simple atomic objects will return false.

    isenabled()
        Returns true if automatic garbage collection is enabled.

    set_debug(flags, /)
        Set the garbage collection debugging flags.

          flags
            An integer that can have the following bits turned on:
              DEBUG_STATS - Print statistics during collection.
              DEBUG_COLLECTABLE - Print collectable objects found.
              DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects
                found.
              DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.
              DEBUG_LEAK - Debug leaking programs (everything but STATS).

        Debugging information is written to sys.stderr.

    set_threshold(...)
        set_threshold(threshold0, [threshold1, threshold2]) -> None

        Sets the collection thresholds.  Setting threshold0 to zero disables
        collection.

    unfreeze()
        Unfreeze all objects in the permanent generation.

        Put all objects in the permanent generation back into oldest generation.

DATA
    DEBUG_COLLECTABLE = 2
    DEBUG_LEAK = 38
    DEBUG_SAVEALL = 32
    DEBUG_STATS = 1
    DEBUG_UNCOLLECTABLE = 4
    callbacks = []
    garbage = []

FILE
    (built-in)



Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 TransitionalValid CSS!

^_back to top