add DO_MEMORY_USAGE

This commit is contained in:
cxgeorge 2002-02-06 01:50:07 +00:00
parent 5800fa36e9
commit 48fbbe3aac
20 changed files with 65 additions and 27 deletions

View File

@ -35,7 +35,9 @@ TypeHandle AnimControl::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
AnimControl:: AnimControl::
AnimControl(PartBundle *part, AnimBundle *anim, int channel_index) { AnimControl(PartBundle *part, AnimBundle *anim, int channel_index) {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
_part = part; _part = part;
_anim = anim; _anim = anim;

View File

@ -133,7 +133,9 @@ TypeHandle GraphicsWindow::WindowPipe::force_init_type(void) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
GraphicsWindow:: GraphicsWindow::
GraphicsWindow(GraphicsPipe *pipe) : Configurable() { GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
_pipe = pipe; _pipe = pipe;
_draw_callback = NULL; _draw_callback = NULL;
@ -150,7 +152,9 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
GraphicsWindow:: GraphicsWindow::
GraphicsWindow(GraphicsPipe *pipe, GraphicsWindow(GraphicsPipe *pipe,
const GraphicsWindow::Properties& props) : Configurable() { const GraphicsWindow::Properties& props) : Configurable() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
_pipe = pipe; _pipe = pipe;
_props = props; _props = props;

View File

@ -16,13 +16,13 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef DO_MEMORY_USAGE
// Nothing in this module gets compiled in NDEBUG mode.
#include "memoryInfo.h" #include "memoryInfo.h"
#include "typedReferenceCount.h" #include "typedReferenceCount.h"
#include "typeHandle.h" #include "typeHandle.h"
#ifndef NDEBUG
// Nothing in this module gets compiled in NDEBUG mode.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MemoryInfo::Constructor // Function: MemoryInfo::Constructor
// Access: Public // Access: Public

View File

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

View File

@ -16,6 +16,8 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef DO_MEMORY_USAGE
// Nothing in this module gets compiled in NDEBUG mode.
#include "memoryUsagePointers.h" #include "memoryUsagePointers.h"
#include "trueClock.h" #include "trueClock.h"
@ -28,10 +30,6 @@
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
#ifndef NDEBUG
// Nothing in this module gets compiled in NDEBUG mode.
#include "config_express.h" #include "config_express.h"
#include <algorithm> #include <algorithm>

View File

@ -21,10 +21,11 @@
#include <pandabase.h> #include <pandabase.h>
#ifdef DO_MEMORY_USAGE
#include "typedObject.h" #include "typedObject.h"
#include "memoryInfo.h" #include "memoryInfo.h"
#include "memoryUsagePointerCounts.h" #include "memoryUsagePointerCounts.h"
#include "pmap.h" #include "pmap.h"
#include "dallocator.h" #include "dallocator.h"
@ -198,6 +199,7 @@ private:
}; };
#include "memoryUsage.I" #include "memoryUsage.I"
#endif
#endif #endif

View File

@ -16,13 +16,12 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef DO_MEMORY_USAGE
// Nothing in this module gets compiled in NDEBUG mode.
#include "memoryUsagePointerCounts.h" #include "memoryUsagePointerCounts.h"
#include "memoryInfo.h" #include "memoryInfo.h"
#ifndef NDEBUG
// Nothing in this module gets compiled in NDEBUG mode.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: MemoryUsagePointerCounts::add_info // Function: MemoryUsagePointerCounts::add_info
// Access: Public // Access: Public

View File

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

View File

@ -16,14 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef DO_MEMORY_USAGE
#include "memoryUsagePointers.h"
#ifndef NDEBUG
// Nothing in this module gets compiled in NDEBUG mode. // Nothing in this module gets compiled in NDEBUG mode.
#include "memoryUsagePointers.h"
#include "config_express.h" #include "config_express.h"
#include "referenceCount.h" #include "referenceCount.h"
#include "typedReferenceCount.h" #include "typedReferenceCount.h"

View File

@ -21,13 +21,13 @@
#include <pandabase.h> #include <pandabase.h>
#ifdef DO_MEMORY_USAGE
#include "typedObject.h" #include "typedObject.h"
#include "pointerTo.h" #include "pointerTo.h"
#include "referenceCount.h" #include "referenceCount.h"
#include "pvector.h" #include "pvector.h"
#ifndef NDEBUG
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : MemoryUsagePointers // Class : MemoryUsagePointers
// Description : This is a list of pointers returned by a MemoryUsage // Description : This is a list of pointers returned by a MemoryUsage

View File

@ -73,7 +73,7 @@ reassign(To *ptr) {
_ptr = ptr; _ptr = ptr;
if (_ptr != (To *)NULL) { if (_ptr != (To *)NULL) {
_ptr->ref(); _ptr->ref();
#ifndef NDEBUG #ifdef DO_MEMORY_USAGE
if (MemoryUsage::get_track_memory_usage()) { if (MemoryUsage::get_track_memory_usage()) {
// Make sure the MemoryUsage record knows what the TypeHandle // Make sure the MemoryUsage record knows what the TypeHandle
// is, if we know it ourselves. // is, if we know it ourselves.

View File

@ -38,7 +38,7 @@ TypeHandle RefCountObj<Base>::_type_handle;
INLINE ReferenceCount:: INLINE ReferenceCount::
ReferenceCount() { ReferenceCount() {
_ref_count = 0; _ref_count = 0;
#ifndef NDEBUG #ifdef DO_MEMORY_USAGE
MemoryUsage::record_pointer(this); MemoryUsage::record_pointer(this);
#endif #endif
} }
@ -56,7 +56,7 @@ ReferenceCount() {
INLINE ReferenceCount:: INLINE ReferenceCount::
ReferenceCount(const ReferenceCount &) { ReferenceCount(const ReferenceCount &) {
_ref_count = 0; _ref_count = 0;
#ifndef NDEBUG #ifdef DO_MEMORY_USAGE
MemoryUsage::record_pointer(this); MemoryUsage::record_pointer(this);
#endif #endif
} }
@ -95,7 +95,7 @@ operator = (const ReferenceCount &) {
INLINE ReferenceCount:: INLINE ReferenceCount::
~ReferenceCount() { ~ReferenceCount() {
prepare_delete(); prepare_delete();
#ifndef NDEBUG #ifdef DO_MEMORY_USAGE
MemoryUsage::remove_pointer(this); MemoryUsage::remove_pointer(this);
#endif #endif
} }

View File

@ -24,7 +24,9 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE TypedReferenceCount:: INLINE TypedReferenceCount::
TypedReferenceCount() { TypedReferenceCount() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -37,7 +39,9 @@ TypedReferenceCount(const TypedReferenceCount &copy) :
TypedObject(copy), TypedObject(copy),
ReferenceCount(copy) ReferenceCount(copy)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -27,7 +27,9 @@ TypeHandle dDrawable::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
dDrawable:: dDrawable::
dDrawable() : WritableConfigurable() { dDrawable() : WritableConfigurable() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -27,7 +27,9 @@ INLINE_GRAPH ArcChain::ArcComponent::
ArcComponent(Node *node) : ArcComponent(Node *node) :
_next(NULL) _next(NULL)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
_p._node = node; _p._node = node;
nassertv(node != (Node *)NULL); nassertv(node != (Node *)NULL);
_p._node->ref(); _p._node->ref();
@ -45,7 +47,9 @@ INLINE_GRAPH ArcChain::ArcComponent::
ArcComponent(NodeRelation *arc, ArcComponent *next) : ArcComponent(NodeRelation *arc, ArcComponent *next) :
_next(next) _next(next)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
_p._arc = arc; _p._arc = arc;
nassertv(_next != (ArcComponent *)NULL); nassertv(_next != (ArcComponent *)NULL);
nassertv(arc != (NodeRelation *)NULL); nassertv(arc != (NodeRelation *)NULL);
@ -62,7 +66,9 @@ INLINE_GRAPH ArcChain::ArcComponent::
ArcComponent(const ArcComponent &copy) : ArcComponent(const ArcComponent &copy) :
_next(copy._next) _next(copy._next)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
if (has_arc()) { if (has_arc()) {
_p._arc = copy._p._arc; _p._arc = copy._p._arc;
nassertv(_p._arc != (NodeRelation *)NULL); nassertv(_p._arc != (NodeRelation *)NULL);

View File

@ -37,7 +37,9 @@ Node* const Node::Null = (Node*)0L;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
Node:: Node::
Node() { Node() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -55,7 +57,9 @@ Node(const Node &copy) :
BoundedObject(copy), BoundedObject(copy),
ReferenceCount(copy) ReferenceCount(copy)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -34,7 +34,9 @@ TypeHandle NodeTransitionCache::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
NodeTransitionCache:: NodeTransitionCache::
NodeTransitionCache() { NodeTransitionCache() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -46,7 +48,9 @@ NodeTransitionCache::
NodeTransitionCache(const NodeTransitionCache &copy) : NodeTransitionCache(const NodeTransitionCache &copy) :
_cache(copy._cache) _cache(copy._cache)
{ {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -67,7 +71,9 @@ operator = (const NodeTransitionCache &copy) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
NodeTransitionCache:: NodeTransitionCache::
NodeTransitionCache(const NodeTransitions &nt) { NodeTransitionCache(const NodeTransitions &nt) {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, get_class_type()); MemoryUsage::update_type(this, get_class_type());
#endif
NodeTransitions::Transitions::const_iterator ti; NodeTransitions::Transitions::const_iterator ti;
for (ti = nt._transitions.begin(); for (ti = nt._transitions.begin();

View File

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

View File

@ -377,6 +377,8 @@ main_tick() {
// code inside the MemoryUsage class, where it fits a little better, // code inside the MemoryUsage class, where it fits a little better,
// simply because MemoryUsage is a very low-level class that doesn't // simply because MemoryUsage is a very low-level class that doesn't
// know about PStatClient. // know about PStatClient.
#ifdef DO_MEMORY_USAGE
if (MemoryUsage::has_total_size()) { if (MemoryUsage::has_total_size()) {
_total_size_pcollector.set_level(MemoryUsage::get_total_size()); _total_size_pcollector.set_level(MemoryUsage::get_total_size());
} }
@ -386,6 +388,7 @@ main_tick() {
if (MemoryUsage::has_interpreter_size()) { if (MemoryUsage::has_interpreter_size()) {
_interpreter_size_pcollector.set_level(MemoryUsage::get_interpreter_size()); _interpreter_size_pcollector.set_level(MemoryUsage::get_interpreter_size());
} }
#endif
get_global_pstats()->client_main_tick(); get_global_pstats()->client_main_tick();
} }

View File

@ -24,7 +24,9 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE TypedWritableReferenceCount:: INLINE TypedWritableReferenceCount::
TypedWritableReferenceCount() { TypedWritableReferenceCount() {
#ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -35,9 +37,10 @@ TypedWritableReferenceCount() {
INLINE TypedWritableReferenceCount:: INLINE TypedWritableReferenceCount::
TypedWritableReferenceCount(const TypedWritableReferenceCount &copy) : TypedWritableReferenceCount(const TypedWritableReferenceCount &copy) :
TypedWritable(copy), TypedWritable(copy),
ReferenceCount(copy) ReferenceCount(copy) {
{ #ifdef DO_MEMORY_USAGE
MemoryUsage::update_type(this, this); MemoryUsage::update_type(this, this);
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////