Browse Source

tracking down memory leaks

David Rose 14 years ago
parent
commit
007b7d3f9e

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

@@ -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;
       }
 

+ 7 - 3
panda/src/express/memoryUsage.cxx

@@ -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);
       }

+ 2 - 0
panda/src/particlesystem/config_particlesystem.cxx

@@ -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();
 }
 

+ 2 - 0
panda/src/pgraph/config_pgraph.cxx

@@ -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();

+ 2 - 1
panda/src/pgraph/geomNode.h

@@ -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);

+ 1 - 0
panda/src/pgraph/pgraph_composite4.cxx

@@ -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"

+ 1 - 0
panda/src/pgraph/sceneSetup.cxx

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

+ 19 - 2
panda/src/pgraph/sceneSetup.h

@@ -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"