tracemalloc.Snapshot.load()

classmethod load(filename) Load a snapshot from a file. See also dump().

tracemalloc.Snapshot.filter_traces()

filter_traces(filters) Create a new Snapshot instance with a filtered traces sequence, filters is a list of Filter instances. If filters is an empty list, return a new Snapshot instance with a copy of the traces. All inclusive filters are applied at once, a trace is ignored if no inclusive filters match it. A trace is ignored if at least one exclusive filter matches it.

tracemalloc.Snapshot.dump()

dump(filename) Write the snapshot into a file. Use load() to reload the snapshot.

tracemalloc.Snapshot.compare_to()

compare_to(old_snapshot: Snapshot, group_by: str, cumulative: bool=False) Compute the differences with an old snapshot. Get statistics as a sorted list of StatisticDiff instances grouped by group_by. See the Snapshot.statistics() method for group_by and cumulative parameters. The result is sorted from the biggest to the smallest by: absolute value of StatisticDiff.size_diff, StatisticDiff.size, absolute value of StatisticDiff.count_diff, Statistic.count and then by StatisticDiff.traceback.

tracemalloc.Snapshot

class tracemalloc.Snapshot Snapshot of traces of memory blocks allocated by Python. The take_snapshot() function creates a snapshot instance. compare_to(old_snapshot: Snapshot, group_by: str, cumulative: bool=False) Compute the differences with an old snapshot. Get statistics as a sorted list of StatisticDiff instances grouped by group_by. See the Snapshot.statistics() method for group_by and cumulative parameters. The result is sorted from the biggest to the smallest by: absolute value o

tracemalloc.is_tracing()

tracemalloc.is_tracing() True if the tracemalloc module is tracing Python memory allocations, False otherwise. See also start() and stop() functions.

tracemalloc.get_tracemalloc_memory()

tracemalloc.get_tracemalloc_memory() Get the memory usage in bytes of the tracemalloc module used to store traces of memory blocks. Return an int.

tracemalloc.get_traced_memory()

tracemalloc.get_traced_memory() Get the current size and peak size of memory blocks traced by the tracemalloc module as a tuple: (current: int, peak: int).

tracemalloc.get_traceback_limit()

tracemalloc.get_traceback_limit() Get the maximum number of frames stored in the traceback of a trace. The tracemalloc module must be tracing memory allocations to get the limit, otherwise an exception is raised. The limit is set by the start() function.

tracemalloc.get_object_traceback()

tracemalloc.get_object_traceback(obj) Get the traceback where the Python object obj was allocated. Return a Traceback instance, or None if the tracemalloc module is not tracing memory allocations or did not trace the allocation of the object. See also gc.get_referrers() and sys.getsizeof() functions.