tracking down memory leaks

This commit is contained in:
David Rose 2011-09-08 02:28:14 +00:00
parent d7ee644809
commit 007b7d3f9e
8 changed files with 37 additions and 7 deletions

View File

@ -114,7 +114,9 @@ determine_dynamic_type() {
_dynamic_type = _static_type;
_flags &= ~F_reconsider_dynamic_type;
//nassert_raise("Unregistered type");
if (ConfigVariableBool("raise-unregistered-type", false).get_value()) {
nassert_raise("Unregistered type");
}
return;
}

View File

@ -96,7 +96,7 @@ show() const {
for (vi = count_sorter.begin(); vi != count_sorter.end(); ++vi) {
TypeHandle type = (*vi)._type;
if (type == TypeHandle::none()) {
nout << "unknown";
nout << "undefined type (TypeHandle::none())";
} else {
nout << type;
}
@ -850,8 +850,12 @@ ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) {
if (info->_freeze_index == _freeze_index &&
info->_ref_ptr != (ReferenceCount *)NULL) {
TypeHandle info_type = info->get_type();
if (info_type != TypeHandle::none() &&
info_type.is_derived_from(type)) {
if (type == TypeHandle::none() &&
info_type == TypeHandle::none()) {
result.add_entry(info->_ref_ptr, info->_typed_ptr, info_type,
now - info->_time);
} else if (info_type != TypeHandle::none() &&
info_type.is_derived_from(type)) {
result.add_entry(info->_ref_ptr, info->_typed_ptr, info_type,
now - info->_time);
}

View File

@ -15,6 +15,7 @@
#include "config_particlesystem.h"
#include "particleSystem.h"
#include "geomParticleRenderer.h"
#include "geomNode.h"
ConfigureDef(config_particlesystem);
NotifyCategoryDef(particlesystem, "");
@ -26,6 +27,7 @@ ConfigureFn(config_particlesystem) {
ColorInterpolationFunctionStepwave::init_type();
ColorInterpolationFunctionSinusoid::init_type();
ParticleSystem::init_type();
GeomNode::GeomList::init_type(); // repeated here to ensure instantiated templates get initialized too.
init_libparticlesystem();
}

View File

@ -72,6 +72,7 @@
#include "renderModeAttrib.h"
#include "renderState.h"
#include "rescaleNormalAttrib.h"
#include "sceneSetup.h"
#include "scissorAttrib.h"
#include "scissorEffect.h"
#include "shadeModelAttrib.h"
@ -490,6 +491,7 @@ init_libpgraph() {
RenderModeAttrib::init_type();
RenderState::init_type();
RescaleNormalAttrib::init_type();
SceneSetup::init_type();
ScissorAttrib::init_type();
ScissorEffect::init_type();
ShadeModelAttrib::init_type();

View File

@ -117,10 +117,11 @@ public:
CPT(RenderState) _state;
};
typedef CopyOnWriteObj< pvector<GeomEntry> > GeomList;
private:
bool _preserved;
typedef CopyOnWriteObj< pvector<GeomEntry> > GeomList;
typedef pmap<const InternalName *, int> NameCount;
INLINE void count_name(NameCount &name_count, const InternalName *name);

View File

@ -6,6 +6,7 @@
#include "renderState.cxx"
#include "rescaleNormalAttrib.cxx"
#include "sceneGraphReducer.cxx"
#include "sceneSetup.cxx"
#include "scissorAttrib.cxx"
#include "scissorEffect.cxx"
#include "shadeModelAttrib.cxx"

View File

@ -14,3 +14,4 @@
#include "sceneSetup.h"
TypeHandle SceneSetup::_type_handle;

View File

@ -17,7 +17,7 @@
#include "pandabase.h"
#include "referenceCount.h"
#include "typedReferenceCount.h"
#include "nodePath.h"
#include "camera.h"
#include "transformState.h"
@ -32,7 +32,7 @@ class DisplayRegion;
// other general setup information for rendering a
// particular scene.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_PGRAPH SceneSetup : public ReferenceCount {
class EXPCL_PANDA_PGRAPH SceneSetup : public TypedReferenceCount {
public:
INLINE SceneSetup();
@ -82,6 +82,23 @@ private:
CPT(RenderState) _initial_state;
CPT(TransformState) _camera_transform;
CPT(TransformState) _world_transform;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
register_type(_type_handle, "SceneSetup",
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#include "sceneSetup.I"