tracemalloc.get_traced_memory()
tracemalloc.get_traced_memory() is a Python function in the Tracemalloc Module category. Returns (current_size, peak_size) of traced memory in bytes. The syntax is tracemalloc.get_traced_memory(). Returns: (current, peak) tuple. A typical example: current, peak = tracemalloc.get_traced_memory()
print(f"Current: {current/1024:.1f} KB, Peak: {peak/1024:.1f} KB"). 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.take_snapshot(), which takes a snapshot of memory allocations. A close sibling is tracemalloc.Snapshot.statistics(), which returns statistics grouped by the given key type ("filename", "lineno", "traceback"). More about this category: Memory tracing — start, stop, get_traced_memory, Snapshot, take_snapshot. Related Tracemalloc Module entries: tracemalloc.start(), tracemalloc.stop(), tracemalloc.take_snapshot(), tracemalloc.Snapshot.statistics(), 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.get_traced_memory() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.