ObjectGraph creation functions¶
Top-level functions for creating ObjectGraph
instances.
- refcycle.creators.cycles_created_by(callable)[source]¶
Return graph of cyclic garbage created by the given callable.
Return an
ObjectGraph
representing those objects generated by the given callable that can’t be collected by Python’s usual reference-count based garbage collection.This includes objects that will eventually be collected by the cyclic garbage collector, as well as genuinely unreachable objects that will never be collected.
callable should be a callable that takes no arguments; its return value (if any) will be ignored.
- refcycle.creators.garbage()[source]¶
Collect garbage and return an
ObjectGraph
based on collected garbage.The collected elements are removed from
gc.garbage
, but are still kept alive by the references in the graph. Deleting theObjectGraph
instance and doing anothergc.collect
will remove those objects for good.
- refcycle.creators.objects_reachable_from(obj)[source]¶
Return graph of objects reachable from obj via
gc.get_referrers
.Returns an
ObjectGraph
object holding all objects reachable from the given one by following the output ofgc.get_referrers
. Note that unlike thesnapshot
function, the output graph may include non-gc-tracked objects.
- refcycle.creators.snapshot()[source]¶
Return the graph of all currently gc-tracked objects.
Excludes the returned
ObjectGraph
and objects owned by it.Note that a subsequent call to
snapshot
will capture all of the objects owned by this snapshot. Theowned_objects
method may be helpful when excluding these objects from consideration.