tracemalloc.Snapshot.statistics()
tracemalloc.Snapshot.statistics() is a Python method in the Tracemalloc Module category. Returns statistics grouped by the given key type ("filename", "lineno", "traceback"). The syntax is Snapshot.statistics(key_type, cumulative=False). Returns: List of Statistic objects. A typical example: stats = snap.statistics("lineno")
for stat in stats[:3]:
print(stat.count, stat.size, stat.traceback). A close sibling is tracemalloc.start(), which starts tracing memory allocations. A close sibling is tracemalloc.stop(), which stops tracing memory allocations. A close sibling is tracemalloc.get_traced_memory(), which returns (current_size, peak_size) of traced memory in bytes. A close sibling is tracemalloc.take_snapshot(), which takes a snapshot of memory allocations. More about this category: Memory tracing — start, stop, get_traced_memory, Snapshot, take_snapshot. Related Tracemalloc Module entries: tracemalloc.start(), tracemalloc.stop(), tracemalloc.get_traced_memory(), tracemalloc.take_snapshot(), tracemalloc.Snapshot.compare_to(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try tracemalloc.Snapshot.statistics() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.