Browse Source

fix OnscreenText memory bloat

David Rose 24 years ago
parent
commit
2187975df5
1 changed files with 11 additions and 2 deletions
  1. 11 2
      panda/src/cull/cullStateLookup.cxx

+ 11 - 2
panda/src/cull/cullStateLookup.cxx

@@ -178,9 +178,18 @@ clean_out_old_nodes() {
   while (csi != _cull_states.end()) {
     ++csnext;
 
+    Node *node = (*csi).first;
     CullState *cs = (*csi).second;
-    if (!cs->has_bin() && cs->is_empty() &&
-        cs->get_empty_frames_count() > 100) {
+
+    if (node->get_ref_count() == 1) {
+      // If we've got the only outstanding pointer to this node,
+      // the node was deleted.  Drop our reference.
+      _cull_states.erase(csi);
+
+    } else if (!cs->has_bin() && cs->is_empty() &&
+               cs->get_empty_frames_count() > 100) {
+      // If the CullState doesn't even have any nodes, delete it after
+      // 100 frames have elapsed.
       _cull_states.erase(csi);
     }
     csi = csnext;