# MemoryUsage

from pandac.PandaModules import MemoryUsage

Class : MemoryUsage
Description : This class is used strictly for debugging purposes, specifically for tracking memory leaks of reference-counted objects: it keeps a record of every such object currently allocated.
When compiled with NDEBUG set, this entire class does nothing and compiles to nothing.

## Inheritance:

MemoryUsage:

## Methods of MemoryUsage:

freeze
getCppSize
getCurrentCppSize
getInterpreterSize
getNumPointers
getPointers
getPointersOfAge
getPointersOfType
getPointersWithZeroCount
getTotalSize
hasCppSize
hasInterpreterSize
hasTotalSize
isCounting
isTracking
showCurrentAges
showCurrentTypes
showTrendAges
showTrendTypes

freeze static void MemoryUsage::freeze(void); Description: 'Freezes' all pointers currently stored so that they are no longer reported; only newly allocate pointers from this point on will appear in future information requests. This makes it easier to differentiate between continuous leaks and one-time memory allocations.

getCppSize static unsigned int MemoryUsage::get_cpp_size(void); Description: Returns the total number of bytes of allocated memory via the C++ operators new and delete as counted, including the memory previously frozen.

getCurrentCppSize static unsigned int MemoryUsage::get_current_cpp_size(void); Description: Returns the total number of bytes of allocated memory via the C++ operators new and delete as counted, not including the memory previously frozen.

getInterpreterSize static unsigned int MemoryUsage::get_interpreter_size(void); Description: Returns the total number of bytes of allocated memory while the high-level languange code is running. This number is only meaningful if both Panda and the high-level language are single-threaded, and running in the same thread.

getNumPointers static int MemoryUsage::get_num_pointers(void); Description: Returns the number of pointers currently active.

getPointers static void MemoryUsage::get_pointers(MemoryUsagePointers &result); Description: Fills the indicated MemoryUsagePointers with the set of all pointers currently active.

getPointersOfAge static void MemoryUsage::get_pointers_of_age(MemoryUsagePointers &result, double from, double to); Description: Fills the indicated MemoryUsagePointers with the set of all pointers that were allocated within the range of the indicated number of seconds ago.

getPointersOfType static void MemoryUsage::get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type); Description: Fills the indicated MemoryUsagePointers with the set of all pointers of the indicated type currently active.

getPointersWithZeroCount static void MemoryUsage::get_pointers_with_zero_count(MemoryUsagePointers &result); Description: Fills the indicated MemoryUsagePointers with the set of all currently active pointers (that is, pointers allocated since the last call to freeze(), and not yet freed) that have a zero reference count. Generally, an undeleted pointer with a zero reference count means its reference count has never been incremented beyond zero (since once it has been incremented, the only way it can return to zero would free the pointer). This may include objects that are allocated statically or on the stack, which are never intended to be deleted. Or, it might represent a programmer or compiler error. This function has the side-effect of incrementing each of their reference counts by one, thus preventing them from ever being freed--but since they hadn't been freed anyway, probably no additional harm is done.

getTotalSize static unsigned int MemoryUsage::get_total_size(void); Description: Returns the total size of the dynamic heap, as nearly as can be determined, including all allocated memory if possible, in addition to that tracked by get_cpp_size().

hasCppSize static bool MemoryUsage::has_cpp_size(void); Description: Returns true if the value returned by get_cpp_size() is meaningful on this particular system with this particular configuration, false otherwise.

hasInterpreterSize static bool MemoryUsage::has_interpreter_size(void); Description: Returns true if the value returned by get_interpreter_size() is meaningful on this particular system with this particular configuration, false otherwise.

hasTotalSize static bool MemoryUsage::has_total_size(void); Description: Returns true if the value returned by get_total_size() is meaningful on this particular system with this particular configuration, false otherwise.

isCounting static bool MemoryUsage::is_counting(void); Description: Returns true if the MemoryUsage object is currently at least counting memory (e.g. count-memory-usage is configured #t), even if it's not fully tracking it.

isTracking static bool MemoryUsage::is_tracking(void); Description: Returns true if the MemoryUsage object is currently tracking memory (e.g. track-memory-usage is configured #t).

showCurrentAges static void MemoryUsage::show_current_ages(void); Description: Shows the breakdown of ages of all of the active pointers.

showCurrentTypes static void MemoryUsage::show_current_types(void); Description: Shows the breakdown of types of all of the active pointers.

showTrendAges static void MemoryUsage::show_trend_ages(void); Description: Shows the breakdown of ages of all of the pointers allocated and freed since the last call to freeze().

showTrendTypes static void MemoryUsage::show_trend_types(void); Description: Shows the breakdown of types of all of the pointers allocated and freed since the last call to freeze().