tracemalloc.start()
tracemalloc.start() is a Python function in the Tracemalloc Module category. Starts tracing memory allocations. The syntax is tracemalloc.start(nframe=1). Returns: None. A typical example: import tracemalloc
tracemalloc.start()
# Your code here
snapshot = tracemalloc.take_snapshot()
for stat in snapshot.statistics("lineno")[:10]:
print(stat). 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. 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.stop(), tracemalloc.get_traced_memory(), 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.start() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.