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
ObjectGraphrepresenting 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
ObjectGraphbased on collected garbage.The collected elements are removed from
gc.garbage, but are still kept alive by the references in the graph. Deleting theObjectGraphinstance and doing anothergc.collectwill 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
ObjectGraphobject holding all objects reachable from the given one by following the output ofgc.get_referrers. Note that unlike thesnapshotfunction, 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
ObjectGraphand objects owned by it.Note that a subsequent call to
snapshotwill capture all of the objects owned by this snapshot. Theowned_objectsmethod may be helpful when excluding these objects from consideration.