module documentation
(source)

Utility for dumping memory usage stats.

This is tailored to mypy and knows (a little) about which list objects are owned by particular AST nodes, etc.

Function collect​_memory​_stats Return stats about memory use.
Function find​_recursive​_objects Find additional objects referenced by objs and append them to objs.
Function print​_memory​_profile Undocumented
def collect_memory_stats(): (source)

Return stats about memory use.

Return a tuple with these items:
  • Dict from object kind to number of instances of that kind
  • Dict from object kind to total bytes used by all instances of that kind
Returns
Tuple[Dict[str, int], Dict[str, int]]Undocumented
def find_recursive_objects(objs): (source)

Find additional objects referenced by objs and append them to objs.

We use this since gc.get_objects() does not return objects without pointers in them such as strings.

Parameters
objs:List[object]Undocumented
def print_memory_profile(run_gc=True): (source)

Undocumented

Parameters
run​_gc:boolUndocumented