jgdv.debugging.malloc_tool
See EOF for license/metadata/notes as applicable
Functions
|
Classes
see tracemalloc |
Module Contents
- jgdv.debugging.malloc_tool.must_be_started(fn) <Unknown>[source]
- Parameters:
fn (collections.abc.Callable[Concatenate[MallocTool, must_be_started.I], must_be_started.O])
- Return type:
collections.abc.Callable[Concatenate[MallocTool, must_be_started.I], must_be_started.O]
- class jgdv.debugging.malloc_tool.MallocTool(*, frame_count=5, logger=None)[source]
see tracemalloc in the stdlib. eg:
with MallocTool(frame_count=2) as dm: dm.whitelist(__file__) dm.blacklist("\*tracemalloc.py", all_frames=False) val = 2 dm.snapshot("simple") vals = [random.random() for x in range(1000)] dm.current() dm.snapshot("list") vals = None dm.current() dm.snapshot("cleared") dm.compare("simple", "list") dm.compare("list", "cleared") dm.compare("list", "simple") dm.inspect("list")
- Parameters:
frame_count (int)
logger (jgdv.Maybe[logging.Logger])
- _get_snapshot(val, *, filter=True) <Unknown>[source]
Retrieve a snapshot, with control of whether it is filtered or not
- Parameters:
- Return type:
- abstractmethod _get_top_n(stats, count=10) <Unknown>[source]
Get the top {count} sized objects of a difference
- Parameters:
stats (list[tracemalloc.StatisticDiff])
count (int)
- Return type:
- _human(num, *, sign=False) <Unknown>[source]
Format a sized number in a human readable way. optionally with a sign prefix
- _print_diff_frames(
- stat,
- *,
- idx=None,
- fullpath=False,
Print a diff, with stacktrace
- Parameters:
stat (tracemalloc.StatisticDiff)
idx (jgdv.Maybe[int])
fullpath (bool)
- Return type:
None
- _print_diff_noframes(
- stat,
- *,
- idx=None,
- fullpath=False,
Print a diff without showing the stacktrace
- Parameters:
stat (tracemalloc.StatisticDiff)
idx (jgdv.Maybe[int])
fullpath (bool)
- Return type:
None
- _print_obj_stat_frames(
- stat,
- *,
- idx=None,
- fullpath=False,
Print a stacktrace for a a given object diff
- compare(
- val1,
- val2,
- *,
- form='traceback',
- filter=True,
- fullpath=False,
- count=10,
Compare two snapshots, with control over filtering, output formatting, and the number of objects to report about
- current(val=None) <Unknown>[source]
Print a brief report about the current memory state
- Parameters:
val (jgdv.Maybe[object])
- Return type:
None
- inspect(
- val,
- *,
- form='traceback',
- filter=True,
- fullpath=False,
Inspect a single snapshot of the memory state
- snapshot(name=None) <Unknown>[source]
Take a snapshot of the current memory state
- Parameters:
name (jgdv.Maybe[str])
- Return type:
None
- whitelist(
- file_pat,
- *,
- lineno=None,
- all_frames=True,
Add a filter to whitelist a file pattern
- _gen_exit_msg = '[TraceMalloc]: -- %s --'
- _logger: logging.Logger
- _stat_line_no_frames_msg = '[TraceMalloc]: (obj:%s) %-15s : %-50s (%s:%s)'
- filters: list[tracemalloc.Filter]
- named_snapshots: dict[str, tracemalloc.Snapshot]
- snapshots: list[tracemalloc.Snapshot]