tracemalloc.StatisticDiff
Prev: tracemalloc.Statistic | Up: tracemalloc | Next: tracemalloc.stop
Rel: tracemalloc.BaseFilter, tracemalloc.clear_traces, tracemalloc.DomainFilter, tracemalloc.Filter
Ref: docs.python.org — tracemalloc.StatisticDiff
Tags: #public #python3 #stdlib #tracemalloc
Import
import tracemalloc
from tracemalloc import StatisticDiff
Signature & Overview
tracemalloc.StatisticDiff(traceback, size, size_diff, count, count_diff)
Statistic difference on memory allocations between an old and a new Snapshot instance.
Usage
import tracemalloc
tracemalloc.start()
try:
s1 = tracemalloc.take_snapshot()
_buf = bytearray(20_000)
s2 = tracemalloc.take_snapshot()
diffs = s2.compare_to(s1, 'lineno')
assert isinstance(diffs[0], tracemalloc.StatisticDiff)
finally:
tracemalloc.stop()
Gotchas
- Best leak-hunting view: Sort by
size_diff(default) to see where memory grew between two checkpoints.
REPL Inspect
from tracemalloc import StatisticDiff
help(StatisticDiff)
Linked from
Related notes
- tuts/python3/stdlib_module/tracemalloc/Statistic Linked here; links to this page; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/stop Linked here; links to this page; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/tracemalloc/BaseFilter Linked here; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/clear_traces Linked here; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/DomainFilter Linked here; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/Filter Linked here; shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/Frame shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/get_object_traceback shared tags: #stdlib, #tracemalloc
- tuts/python3/stdlib_module/tracemalloc/get_traceback_limit shared tags: #stdlib, #tracemalloc