diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 528c02ff0a..3401376f9e 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -35,7 +35,9 @@ TypeHandle AnimControl::_type_handle; //////////////////////////////////////////////////////////////////// AnimControl:: AnimControl(PartBundle *part, AnimBundle *anim, int channel_index) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif _part = part; _anim = anim; diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index e892702544..7f6e7453c0 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -133,7 +133,9 @@ TypeHandle GraphicsWindow::WindowPipe::force_init_type(void) { //////////////////////////////////////////////////////////////////// GraphicsWindow:: GraphicsWindow(GraphicsPipe *pipe) : Configurable() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif _pipe = pipe; _draw_callback = NULL; @@ -150,7 +152,9 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() { GraphicsWindow:: GraphicsWindow(GraphicsPipe *pipe, const GraphicsWindow::Properties& props) : Configurable() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif _pipe = pipe; _props = props; diff --git a/panda/src/express/memoryInfo.cxx b/panda/src/express/memoryInfo.cxx index 83d06fb83d..aadd73b9e7 100644 --- a/panda/src/express/memoryInfo.cxx +++ b/panda/src/express/memoryInfo.cxx @@ -16,13 +16,13 @@ // //////////////////////////////////////////////////////////////////// +#ifdef DO_MEMORY_USAGE +// Nothing in this module gets compiled in NDEBUG mode. + #include "memoryInfo.h" #include "typedReferenceCount.h" #include "typeHandle.h" -#ifndef NDEBUG -// Nothing in this module gets compiled in NDEBUG mode. - //////////////////////////////////////////////////////////////////// // Function: MemoryInfo::Constructor // Access: Public diff --git a/panda/src/express/memoryInfo.h b/panda/src/express/memoryInfo.h index 306b73bc78..04260cbbc1 100644 --- a/panda/src/express/memoryInfo.h +++ b/panda/src/express/memoryInfo.h @@ -20,12 +20,14 @@ #define MEMORYINFO_H #include + +#ifdef DO_MEMORY_USAGE + #include "typeHandle.h" class ReferenceCount; class TypedObject; -#ifndef NDEBUG //////////////////////////////////////////////////////////////////// // Class : MemoryInfo // Description : This is a supporting class for MemoryUsage. It diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index fc8c140405..878e982a52 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -16,6 +16,8 @@ // //////////////////////////////////////////////////////////////////// +#ifdef DO_MEMORY_USAGE +// Nothing in this module gets compiled in NDEBUG mode. #include "memoryUsagePointers.h" #include "trueClock.h" @@ -28,10 +30,6 @@ #include #endif -#ifndef NDEBUG -// Nothing in this module gets compiled in NDEBUG mode. - - #include "config_express.h" #include diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index fac58925a5..95d7bdb937 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -21,10 +21,11 @@ #include +#ifdef DO_MEMORY_USAGE + #include "typedObject.h" #include "memoryInfo.h" #include "memoryUsagePointerCounts.h" - #include "pmap.h" #include "dallocator.h" @@ -198,6 +199,7 @@ private: }; #include "memoryUsage.I" +#endif #endif diff --git a/panda/src/express/memoryUsagePointerCounts.cxx b/panda/src/express/memoryUsagePointerCounts.cxx index 0d4779664a..fb1825c9b1 100644 --- a/panda/src/express/memoryUsagePointerCounts.cxx +++ b/panda/src/express/memoryUsagePointerCounts.cxx @@ -16,13 +16,12 @@ // //////////////////////////////////////////////////////////////////// +#ifdef DO_MEMORY_USAGE +// Nothing in this module gets compiled in NDEBUG mode. #include "memoryUsagePointerCounts.h" #include "memoryInfo.h" -#ifndef NDEBUG -// Nothing in this module gets compiled in NDEBUG mode. - //////////////////////////////////////////////////////////////////// // Function: MemoryUsagePointerCounts::add_info // Access: Public diff --git a/panda/src/express/memoryUsagePointerCounts.h b/panda/src/express/memoryUsagePointerCounts.h index 4e98c44c1e..5ae6f13b90 100644 --- a/panda/src/express/memoryUsagePointerCounts.h +++ b/panda/src/express/memoryUsagePointerCounts.h @@ -21,9 +21,10 @@ #include +#ifdef DO_MEMORY_USAGE + class MemoryInfo; -#ifndef NDEBUG //////////////////////////////////////////////////////////////////// // Class : MemoryUsagePointerCounts // Description : This is a supporting class for MemoryUsage. It diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index ed900ee2b2..cdfb25e01c 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -16,14 +16,10 @@ // //////////////////////////////////////////////////////////////////// - -#include "memoryUsagePointers.h" - - -#ifndef NDEBUG +#ifdef DO_MEMORY_USAGE // Nothing in this module gets compiled in NDEBUG mode. - +#include "memoryUsagePointers.h" #include "config_express.h" #include "referenceCount.h" #include "typedReferenceCount.h" diff --git a/panda/src/express/memoryUsagePointers.h b/panda/src/express/memoryUsagePointers.h index 4985422b09..50b2550d9a 100644 --- a/panda/src/express/memoryUsagePointers.h +++ b/panda/src/express/memoryUsagePointers.h @@ -21,13 +21,13 @@ #include +#ifdef DO_MEMORY_USAGE + #include "typedObject.h" #include "pointerTo.h" #include "referenceCount.h" - #include "pvector.h" -#ifndef NDEBUG //////////////////////////////////////////////////////////////////// // Class : MemoryUsagePointers // Description : This is a list of pointers returned by a MemoryUsage diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index 42b766af30..fc602f9fb7 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -73,7 +73,7 @@ reassign(To *ptr) { _ptr = ptr; if (_ptr != (To *)NULL) { _ptr->ref(); -#ifndef NDEBUG +#ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { // Make sure the MemoryUsage record knows what the TypeHandle // is, if we know it ourselves. diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index 439f318a63..cc37c55336 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -38,7 +38,7 @@ TypeHandle RefCountObj::_type_handle; INLINE ReferenceCount:: ReferenceCount() { _ref_count = 0; -#ifndef NDEBUG +#ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); #endif } @@ -56,7 +56,7 @@ ReferenceCount() { INLINE ReferenceCount:: ReferenceCount(const ReferenceCount &) { _ref_count = 0; -#ifndef NDEBUG +#ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); #endif } @@ -95,7 +95,7 @@ operator = (const ReferenceCount &) { INLINE ReferenceCount:: ~ReferenceCount() { prepare_delete(); -#ifndef NDEBUG +#ifdef DO_MEMORY_USAGE MemoryUsage::remove_pointer(this); #endif } diff --git a/panda/src/express/typedReferenceCount.I b/panda/src/express/typedReferenceCount.I index d09d14097a..5bdc42d5e2 100644 --- a/panda/src/express/typedReferenceCount.I +++ b/panda/src/express/typedReferenceCount.I @@ -24,7 +24,9 @@ //////////////////////////////////////////////////////////////////// INLINE TypedReferenceCount:: TypedReferenceCount() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// @@ -37,7 +39,9 @@ TypedReferenceCount(const TypedReferenceCount ©) : TypedObject(copy), ReferenceCount(copy) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/drawable.cxx b/panda/src/gobj/drawable.cxx index f979e1e10d..831f7395d4 100644 --- a/panda/src/gobj/drawable.cxx +++ b/panda/src/gobj/drawable.cxx @@ -27,7 +27,9 @@ TypeHandle dDrawable::_type_handle; //////////////////////////////////////////////////////////////////// dDrawable:: dDrawable() : WritableConfigurable() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/graph/arcChain.I b/panda/src/graph/arcChain.I index 71c6889d32..6b1ea7d8ff 100644 --- a/panda/src/graph/arcChain.I +++ b/panda/src/graph/arcChain.I @@ -27,7 +27,9 @@ INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(Node *node) : _next(NULL) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif _p._node = node; nassertv(node != (Node *)NULL); _p._node->ref(); @@ -45,7 +47,9 @@ INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(NodeRelation *arc, ArcComponent *next) : _next(next) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif _p._arc = arc; nassertv(_next != (ArcComponent *)NULL); nassertv(arc != (NodeRelation *)NULL); @@ -62,7 +66,9 @@ INLINE_GRAPH ArcChain::ArcComponent:: ArcComponent(const ArcComponent ©) : _next(copy._next) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif if (has_arc()) { _p._arc = copy._p._arc; nassertv(_p._arc != (NodeRelation *)NULL); diff --git a/panda/src/graph/node.cxx b/panda/src/graph/node.cxx index ff38836f54..eb67000c5c 100644 --- a/panda/src/graph/node.cxx +++ b/panda/src/graph/node.cxx @@ -37,7 +37,9 @@ Node* const Node::Null = (Node*)0L; //////////////////////////////////////////////////////////////////// Node:: Node() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// @@ -55,7 +57,9 @@ Node(const Node ©) : BoundedObject(copy), ReferenceCount(copy) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/graph/nodeTransitionCache.cxx b/panda/src/graph/nodeTransitionCache.cxx index 0b95ea8f99..b91ae5e88c 100644 --- a/panda/src/graph/nodeTransitionCache.cxx +++ b/panda/src/graph/nodeTransitionCache.cxx @@ -34,7 +34,9 @@ TypeHandle NodeTransitionCache::_type_handle; //////////////////////////////////////////////////////////////////// NodeTransitionCache:: NodeTransitionCache() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif } //////////////////////////////////////////////////////////////////// @@ -46,7 +48,9 @@ NodeTransitionCache:: NodeTransitionCache(const NodeTransitionCache ©) : _cache(copy._cache) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif } //////////////////////////////////////////////////////////////////// @@ -67,7 +71,9 @@ operator = (const NodeTransitionCache ©) { //////////////////////////////////////////////////////////////////// NodeTransitionCache:: NodeTransitionCache(const NodeTransitions &nt) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); +#endif NodeTransitions::Transitions::const_iterator ti; for (ti = nt._transitions.begin(); diff --git a/panda/src/pandabase/pandabase.h b/panda/src/pandabase/pandabase.h index 4d9af3ec56..e2cf4b46c2 100644 --- a/panda/src/pandabase/pandabase.h +++ b/panda/src/pandabase/pandabase.h @@ -26,5 +26,11 @@ #include #include "pandasymbols.h" +#if defined(UNKNOWN_ALLOCATOR) || defined(NDEBUG) +#undef DO_MEMORY_USAGE +#else +#define DO_MEMORY_USAGE +#endif + #endif diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 89206b3645..6222751a24 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -377,6 +377,8 @@ main_tick() { // code inside the MemoryUsage class, where it fits a little better, // simply because MemoryUsage is a very low-level class that doesn't // know about PStatClient. + +#ifdef DO_MEMORY_USAGE if (MemoryUsage::has_total_size()) { _total_size_pcollector.set_level(MemoryUsage::get_total_size()); } @@ -386,6 +388,7 @@ main_tick() { if (MemoryUsage::has_interpreter_size()) { _interpreter_size_pcollector.set_level(MemoryUsage::get_interpreter_size()); } +#endif get_global_pstats()->client_main_tick(); } diff --git a/panda/src/putil/typedWritableReferenceCount.I b/panda/src/putil/typedWritableReferenceCount.I index 622a8c3663..08057ff5ee 100644 --- a/panda/src/putil/typedWritableReferenceCount.I +++ b/panda/src/putil/typedWritableReferenceCount.I @@ -24,7 +24,9 @@ //////////////////////////////////////////////////////////////////// INLINE TypedWritableReferenceCount:: TypedWritableReferenceCount() { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } //////////////////////////////////////////////////////////////////// @@ -35,9 +37,10 @@ TypedWritableReferenceCount() { INLINE TypedWritableReferenceCount:: TypedWritableReferenceCount(const TypedWritableReferenceCount ©) : TypedWritable(copy), - ReferenceCount(copy) -{ + ReferenceCount(copy) { +#ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); +#endif } ////////////////////////////////////////////////////////////////////