tracemalloc.StatisticDiff.count

count Number of memory blocks in the new snapshot (int): 0 if the memory blocks have been released in the new snapshot.

tracemalloc.StatisticDiff

class tracemalloc.StatisticDiff Statistic difference on memory allocations between an old and a new Snapshot instance. Snapshot.compare_to() returns a list of StatisticDiff instances. See also the Statistic class. count Number of memory blocks in the new snapshot (int): 0 if the memory blocks have been released in the new snapshot. count_diff Difference of number of memory blocks between the old and the new snapshots (int): 0 if the memory blocks have been allocated in the new snaps

tracemalloc.Statistic.traceback

traceback Traceback where the memory block was allocated, Traceback instance.

tracemalloc.Statistic.size

size Total size of memory blocks in bytes (int).

tracemalloc.Statistic.count

count Number of memory blocks (int).

tracemalloc.Statistic

class tracemalloc.Statistic Statistic on memory allocations. Snapshot.statistics() returns a list of Statistic instances. See also the StatisticDiff class. count Number of memory blocks (int). size Total size of memory blocks in bytes (int). traceback Traceback where the memory block was allocated, Traceback instance.

tracemalloc.start()

tracemalloc.start(nframe: int=1) Start tracing Python memory allocations: install hooks on Python memory allocators. Collected tracebacks of traces will be limited to nframe frames. By default, a trace of a memory block only stores the most recent frame: the limit is 1. nframe must be greater or equal to 1. Storing more than 1 frame is only useful to compute statistics grouped by 'traceback' or to compute cumulative statistics: see the Snapshot.compare_to() and Snapshot.statistics() methods.

tracemalloc.Snapshot.traces

traces Traces of all memory blocks allocated by Python: sequence of Trace instances. The sequence has an undefined order. Use the Snapshot.statistics() method to get a sorted list of statistics.

tracemalloc.Snapshot.traceback_limit

traceback_limit Maximum number of frames stored in the traceback of traces: result of the get_traceback_limit() when the snapshot was taken.

tracemalloc.Snapshot.statistics()

statistics(group_by: str, cumulative: bool=False) Get statistics as a sorted list of Statistic instances grouped by group_by: group_by description 'filename' filename 'lineno' filename and line number 'traceback' traceback If cumulative is True, cumulate size and count of memory blocks of all frames of the traceback of a trace, not only the most recent frame. The cumulative mode can only be used with group_by equals to 'filename' and 'lineno'. The result is sorted from the biggest to the s