37 ALWAYS_INLINE
static bool get_track_memory_usage();
40 INLINE
static void record_pointer(
void *ptr,
TypeHandle type);
43 INLINE
static void update_type(
void *ptr,
TypeHandle type);
58 #if (defined(WIN32_VC) || defined(WIN64_VC)) && defined(_DEBUG) 59 static int win32_malloc_hook(
int alloc_type,
void *ptr,
60 size_t size,
int block_use,
long request,
61 const unsigned char *filename,
int line);
65 INLINE
static bool is_tracking();
66 INLINE
static bool is_counting();
67 INLINE
static size_t get_current_cpp_size();
68 INLINE
static size_t get_total_cpp_size();
70 INLINE
static size_t get_panda_heap_single_size();
71 INLINE
static size_t get_panda_heap_array_size();
72 INLINE
static size_t get_panda_heap_overhead();
73 INLINE
static size_t get_panda_mmap_size();
74 INLINE
static size_t get_external_size();
75 INLINE
static size_t get_total_size();
77 INLINE
static int get_num_pointers();
82 double from,
double to);
85 INLINE
static void freeze();
87 INLINE
static void show_current_types();
88 INLINE
static void show_trend_types();
89 INLINE
static void show_current_ages();
90 INLINE
static void show_trend_ages();
93 MAKE_PROPERTY(tracking, is_tracking);
94 MAKE_PROPERTY(counting, is_counting);
95 MAKE_PROPERTY(current_cpp_size, get_current_cpp_size);
96 MAKE_PROPERTY(total_cpp_size, get_total_cpp_size);
98 MAKE_PROPERTY(panda_heap_single_size, get_panda_heap_single_size);
99 MAKE_PROPERTY(panda_heap_array_size, get_panda_heap_array_size);
100 MAKE_PROPERTY(panda_heap_overhead, get_panda_heap_overhead);
101 MAKE_PROPERTY(panda_mmap_size, get_panda_mmap_size);
102 MAKE_PROPERTY(external_size, get_external_size);
103 MAKE_PROPERTY(total_size, get_total_size);
106 virtual void overflow_heap_size();
112 static void init_memory_usage();
115 void ns_record_pointer(
void *ptr,
TypeHandle type);
116 void ns_update_type(
void *ptr,
TypeHandle type);
117 void ns_update_type(
void *ptr,
TypedObject *typed_ptr);
120 void ns_record_void_pointer(
void *ptr,
size_t size);
121 void ns_remove_void_pointer(
void *ptr);
123 size_t ns_get_total_size();
124 int ns_get_num_pointers();
129 double from,
double to);
133 void ns_show_current_types();
134 void ns_show_trend_types();
135 void ns_show_current_ages();
136 void ns_show_trend_ages();
138 #ifdef DO_MEMORY_USAGE 139 void consolidate_void_ptr(MemoryInfo *info);
140 void refresh_info_set();
159 typedef std::map<void *, MemoryInfo *> Table;
164 typedef std::set<MemoryInfo *> InfoSet;
166 bool _info_set_dirty;
170 size_t _current_cpp_size;
171 size_t _total_cpp_size;
174 class TypeHistogram {
176 void add_info(
TypeHandle type, MemoryInfo *info);
182 typedef std::map<TypeHandle, MemoryUsagePointerCounts> Counts;
185 TypeHistogram _trend_types;
190 void add_info(
double age, MemoryInfo *info);
195 int choose_bucket(
double age)
const;
197 enum { num_buckets = 5 };
199 static double _cutoff[num_buckets];
201 AgeHistogram _trend_ages;
204 bool _track_memory_usage;
205 bool _startup_track_memory_usage;
206 bool _count_memory_usage;
207 bool _report_memory_usage;
208 double _report_memory_interval;
209 double _last_report_time;
211 static bool _recursion_protect;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void heap_free_array(void *ptr)
Releases a block of memory previously allocated via heap_alloc_array.
virtual void * heap_alloc_single(size_t size)
Allocates a block of memory from the heap, similar to malloc().
virtual void mark_pointer(void *ptr, size_t orig_size, ReferenceCount *ref_ptr)
This special method exists only to provide a callback hook into MemoryUsage.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a list of pointers returned by a MemoryUsage object in response to some query.
virtual void heap_free_single(void *ptr)
Releases a block of memory previously allocated via heap_alloc_single.
This class is used strictly for debugging purposes, specifically for tracking memory leaks of referen...
A base class for all things that want to be reference-counted.
virtual void * heap_alloc_array(size_t size)
Allocates a block of memory from the heap, similar to malloc().
This class provides a wrapper around the various possible malloc schemes Panda might employ.
virtual void * heap_realloc_array(void *ptr, size_t size)
Resizes a block of memory previously returned from heap_alloc_array.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
This is a supporting class for MemoryUsage.