21 #ifdef DO_MEMORY_USAGE 22 return get_global_ptr()->_track_memory_usage;
33 #ifdef DO_MEMORY_USAGE 34 get_global_ptr()->ns_record_pointer(ptr);
43 #ifdef DO_MEMORY_USAGE 44 get_global_ptr()->ns_record_pointer(ptr, type);
56 #ifdef DO_MEMORY_USAGE 57 get_global_ptr()->ns_update_type((
void *)ptr, type);
69 #ifdef DO_MEMORY_USAGE 70 get_global_ptr()->ns_update_type((
void *)ptr, typed_ptr);
81 #ifdef DO_MEMORY_USAGE 82 get_global_ptr()->ns_update_type(ptr, type);
91 #ifdef DO_MEMORY_USAGE 92 get_global_ptr()->ns_remove_pointer(ptr);
100 INLINE
bool MemoryUsage::
102 #ifdef DO_MEMORY_USAGE 103 return get_global_ptr()->_track_memory_usage;
114 INLINE
bool MemoryUsage::
116 #ifdef DO_MEMORY_USAGE 117 return get_global_ptr()->_count_memory_usage;
127 INLINE
size_t MemoryUsage::
128 get_current_cpp_size() {
129 #ifdef DO_MEMORY_USAGE 130 return get_global_ptr()->_current_cpp_size;
140 INLINE
size_t MemoryUsage::
141 get_total_cpp_size() {
142 #ifdef DO_MEMORY_USAGE 143 return get_global_ptr()->_total_cpp_size;
153 INLINE
size_t MemoryUsage::
154 get_panda_heap_single_size() {
155 #ifdef DO_MEMORY_USAGE 166 INLINE
size_t MemoryUsage::
167 get_panda_heap_array_size() {
168 #ifdef DO_MEMORY_USAGE 180 INLINE
size_t MemoryUsage::
181 get_panda_heap_overhead() {
182 #if defined(DO_MEMORY_USAGE) && (defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2)) 194 INLINE
size_t MemoryUsage::
195 get_panda_mmap_size() {
196 #ifdef DO_MEMORY_USAGE 215 INLINE
size_t MemoryUsage::
216 get_external_size() {
217 #ifdef DO_MEMORY_USAGE 219 if (mu->_count_memory_usage) {
223 #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) 226 return mu->_total_size;
230 return mu->_total_size - (size_t)mu->_total_heap_single_size - (
size_t)mu->_total_heap_array_size;
244 INLINE
size_t MemoryUsage::
246 #ifdef DO_MEMORY_USAGE 248 if (mu->_count_memory_usage) {
249 return mu->_total_size + (size_t)mu->_requested_heap_size;
251 #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) 252 return (
size_t)mu->_requested_heap_size;
267 #ifdef DO_MEMORY_USAGE 268 return get_global_ptr()->ns_get_num_pointers();
280 #ifdef DO_MEMORY_USAGE 281 get_global_ptr()->ns_get_pointers(result);
291 #ifdef DO_MEMORY_USAGE 292 get_global_ptr()->ns_get_pointers_of_type(result, type);
302 #ifdef DO_MEMORY_USAGE 303 get_global_ptr()->ns_get_pointers_of_age(result, from, to);
325 #ifdef DO_MEMORY_USAGE 326 get_global_ptr()->ns_get_pointers_with_zero_count(result);
338 #ifdef DO_MEMORY_USAGE 339 get_global_ptr()->ns_freeze();
348 #ifdef DO_MEMORY_USAGE 349 get_global_ptr()->ns_show_current_types();
359 #ifdef DO_MEMORY_USAGE 360 get_global_ptr()->ns_show_trend_types();
369 #ifdef DO_MEMORY_USAGE 370 get_global_ptr()->ns_show_current_ages();
380 #ifdef DO_MEMORY_USAGE 381 get_global_ptr()->ns_show_trend_ages();
390 #ifdef DO_MEMORY_USAGE 393 if (__builtin_expect(_global_ptr ==
nullptr, 0)) {
395 if (_global_ptr ==
nullptr) {
static void get_pointers_with_zero_count(MemoryUsagePointers &result)
Fills the indicated MemoryUsagePointers with the set of all currently active pointers (that is...
static ALWAYS_INLINE bool get_track_memory_usage()
Returns true if the user has Configured the variable 'track-memory-usage' to true, indicating that this class will be in effect.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
static void get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type)
Fills the indicated MemoryUsagePointers with the set of all pointers of the indicated type currently ...
static void show_trend_ages()
Shows the breakdown of ages of all of the pointers allocated and freed since the last call to freeze(...
static int get_num_pointers()
Returns the number of pointers currently active.
static void get_pointers(MemoryUsagePointers &result)
Fills the indicated MemoryUsagePointers with the set of all pointers currently active.
This is a list of pointers returned by a MemoryUsage object in response to some query.
static void remove_pointer(ReferenceCount *ptr)
Indicates that the given pointer has been recently freed.
static void freeze()
'Freezes' all pointers currently stored so that they are no longer reported; only newly allocate poin...
This class is used strictly for debugging purposes, specifically for tracking memory leaks of referen...
static ALWAYS_INLINE Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
static void show_trend_types()
Shows the breakdown of types of all of the pointers allocated and freed since the last call to freeze...
static void update_type(ReferenceCount *ptr, TypeHandle type)
Associates the indicated type with the given pointer.
static void get_pointers_of_age(MemoryUsagePointers &result, double from, double to)
Fills the indicated MemoryUsagePointers with the set of all pointers that were allocated within the r...
A base class for all things that want to be reference-counted.
static void show_current_types()
Shows the breakdown of types of all of the active pointers.
static void show_current_ages()
Shows the breakdown of ages of all of the active pointers.
TypeHandle is the identifier used to differentiate C++ class types.
static void record_pointer(ReferenceCount *ptr)
Indicates that the given pointer has been recently allocated.