Skip to content

Commit 925ce85

Browse files
committed
general: make DO_MEMORY_USAGE setting not change ABI compatibility
1 parent 5fffbbc commit 925ce85

27 files changed

+334
-128
lines changed

dtool/src/dtoolbase/memoryHook.cxx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -202,33 +202,28 @@ MemoryHook() {
202202

203203
#endif // WIN32
204204

205-
#ifdef DO_MEMORY_USAGE
206205
_total_heap_single_size = 0;
207206
_total_heap_array_size = 0;
208207
_requested_heap_size = 0;
209208
_total_mmap_size = 0;
210209
_max_heap_size = ~(size_t)0;
211-
#endif
212210
}
213211

214212
/**
215213
*
216214
*/
217215
MemoryHook::
218216
MemoryHook(const MemoryHook &copy) :
219-
_page_size(copy._page_size)
220-
{
221-
#ifdef DO_MEMORY_USAGE
222-
_total_heap_single_size = copy._total_heap_single_size;
223-
_total_heap_array_size = copy._total_heap_array_size;
224-
_requested_heap_size = copy._requested_heap_size;
225-
_total_mmap_size = copy._total_mmap_size;
226-
_max_heap_size = copy._max_heap_size;
227-
#endif
228-
229-
((MutexImpl &)copy._lock).acquire();
217+
_page_size(copy._page_size),
218+
_total_heap_single_size(copy._total_heap_single_size),
219+
_total_heap_array_size(copy._total_heap_array_size),
220+
_requested_heap_size(copy._requested_heap_size),
221+
_total_mmap_size(copy._total_mmap_size),
222+
_max_heap_size(copy._max_heap_size) {
223+
224+
copy._lock.acquire();
230225
_deleted_chains = copy._deleted_chains;
231-
((MutexImpl &)copy._lock).release();
226+
copy._lock.release();
232227
}
233228

234229
/**
@@ -631,7 +626,6 @@ alloc_fail(size_t attempted_size) {
631626
abort();
632627
}
633628

634-
#ifdef DO_MEMORY_USAGE
635629
/**
636630
* This callback method is called whenever the total allocated heap size
637631
* exceeds _max_heap_size. It's mainly intended for reporting memory leaks,
@@ -642,6 +636,7 @@ alloc_fail(size_t attempted_size) {
642636
*/
643637
void MemoryHook::
644638
overflow_heap_size() {
639+
#ifdef DO_MEMORY_USAGE
645640
_max_heap_size = ~(size_t)0;
646-
}
647641
#endif // DO_MEMORY_USAGE
642+
}

dtool/src/dtoolbase/memoryHook.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class EXPCL_DTOOL MemoryHook {
6767

6868
INLINE static size_t get_ptr_size(void *ptr);
6969

70-
#ifdef DO_MEMORY_USAGE
7170
protected:
7271
TVOLATILE AtomicAdjust::Integer _total_heap_single_size;
7372
TVOLATILE AtomicAdjust::Integer _total_heap_array_size;
@@ -79,15 +78,14 @@ class EXPCL_DTOOL MemoryHook {
7978
size_t _max_heap_size;
8079

8180
virtual void overflow_heap_size();
82-
#endif // DO_MEMORY_USAGE
8381

8482
private:
8583
size_t _page_size;
8684

8785
typedef map<size_t, DeletedBufferChain *> DeletedChains;
8886
DeletedChains _deleted_chains;
8987

90-
MutexImpl _lock;
88+
mutable MutexImpl _lock;
9189
};
9290

9391
#include "memoryHook.I"

dtool/src/dtoolbase/typeRegistryNode.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref) :
2626
_handle(handle), _name(name), _ref(ref)
2727
{
2828
clear_subtree();
29-
#ifdef DO_MEMORY_USAGE
3029
memset(_memory_usage, 0, sizeof(_memory_usage));
31-
#endif
3230
}
3331

3432
/**

dtool/src/dtoolbase/typeRegistryNode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ class EXPCL_DTOOL TypeRegistryNode {
4747
Classes _parent_classes;
4848
Classes _child_classes;
4949

50-
#ifdef DO_MEMORY_USAGE
5150
AtomicAdjust::Integer _memory_usage[TypeHandle::MC_limit];
52-
#endif
5351

5452
static bool _paranoid_inheritance;
5553

panda/src/express/memoryInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class MemoryInfo {
7575

7676
#include "memoryInfo.I"
7777

78+
#else
79+
class MemoryInfo;
80+
7881
#endif // DO_MEMORY_USAGE
7982

8083
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy