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;