cxgeorge 24 роки тому
батько
коміт
48fbbe3aac

+ 2 - 0
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;

+ 4 - 0
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;
 

+ 3 - 3
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

+ 3 - 1
panda/src/express/memoryInfo.h

@@ -20,12 +20,14 @@
 #define MEMORYINFO_H
 
 #include <pandabase.h>
+
+#ifdef DO_MEMORY_USAGE
+
 #include "typeHandle.h"
 
 class ReferenceCount;
 class TypedObject;
 
-#ifndef NDEBUG
 ////////////////////////////////////////////////////////////////////
 //       Class : MemoryInfo
 // Description : This is a supporting class for MemoryUsage.  It

+ 2 - 4
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 <crtdbg.h>
 #endif
 
-#ifndef NDEBUG
-// Nothing in this module gets compiled in NDEBUG mode.
-
-
 #include "config_express.h"
 #include <algorithm>
 

+ 3 - 1
panda/src/express/memoryUsage.h

@@ -21,10 +21,11 @@
 
 #include <pandabase.h>
 
+#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
 

+ 2 - 3
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

+ 2 - 1
panda/src/express/memoryUsagePointerCounts.h

@@ -21,9 +21,10 @@
 
 #include <pandabase.h>
 
+#ifdef DO_MEMORY_USAGE
+
 class MemoryInfo;
 
-#ifndef NDEBUG
 ////////////////////////////////////////////////////////////////////
 //       Class : MemoryUsagePointerCounts
 // Description : This is a supporting class for MemoryUsage.  It

+ 2 - 6
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"

+ 2 - 2
panda/src/express/memoryUsagePointers.h

@@ -21,13 +21,13 @@
 
 #include <pandabase.h>
 
+#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

+ 1 - 1
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.

+ 3 - 3
panda/src/express/referenceCount.I

@@ -38,7 +38,7 @@ TypeHandle RefCountObj<Base>::_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
 }

+ 4 - 0
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 &copy) :
   TypedObject(copy),
   ReferenceCount(copy)
 {
+#ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, this);
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////

+ 2 - 0
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
 }
 
 ////////////////////////////////////////////////////////////////////

+ 6 - 0
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 &copy) :
   _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);

+ 4 - 0
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 &copy) :
   BoundedObject(copy),
   ReferenceCount(copy)
 {
+#ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, this);
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////

+ 6 - 0
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 &copy) :
   _cache(copy._cache)
 {
+#ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, get_class_type());
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -67,7 +71,9 @@ operator = (const NodeTransitionCache &copy) {
 ////////////////////////////////////////////////////////////////////
 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();

+ 6 - 0
panda/src/pandabase/pandabase.h

@@ -26,5 +26,11 @@
 #include <dtoolbase.h>
 #include "pandasymbols.h"
 
+#if defined(UNKNOWN_ALLOCATOR) || defined(NDEBUG)
+#undef DO_MEMORY_USAGE
+#else
+#define DO_MEMORY_USAGE
+#endif
+
 #endif
 

+ 3 - 0
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();
 }  

+ 5 - 2
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 &copy) :
   TypedWritable(copy),
-  ReferenceCount(copy)
-{
+  ReferenceCount(copy) {
+#ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, this);
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////