Browse Source

pgraph: Track CullableObject memory usage

rdb 3 months ago
parent
commit
d65e46e7b7
1 changed files with 14 additions and 1 deletions
  1. 14 1
      panda/src/pgraph/cullResult.cxx

+ 14 - 1
panda/src/pgraph/cullResult.cxx

@@ -65,7 +65,10 @@ CullResult(GraphicsStateGuardianBase *gsg,
 
 #ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, get_class_type());
-#endif
+
+  CullableObject::get_class_type().inc_memory_usage(
+    TypeHandle::MC_array, sizeof(CullableObject) * AllocationPage::_capacity);
+#endif  // DO_MEMORY_USAGE
 
 #ifndef NDEBUG
   _show_transparency = show_transparency.get_value();
@@ -372,6 +375,10 @@ make_new_bin(int bin_index) {
 CullResult::AllocationPage *CullResult::
 new_page() {
   AllocationPage *page = new AllocationPage;
+#ifdef DO_MEMORY_USAGE
+  CullableObject::get_class_type().inc_memory_usage(
+    TypeHandle::MC_array, sizeof(CullableObject) * AllocationPage::_capacity);
+#endif  // DO_MEMORY_USAGE
   page->_next = _page;
   _page = page;
   return page;
@@ -389,6 +396,12 @@ delete_page(AllocationPage *page) {
     //MemoryUsage::remove_void_pointer(&((CullableObject *)page->_memory)[i]);
 #endif
   }
+
+#ifdef DO_MEMORY_USAGE
+  CullableObject::get_class_type().dec_memory_usage(
+    TypeHandle::MC_array, sizeof(CullableObject) * AllocationPage::_capacity);
+#endif  // DO_MEMORY_USAGE
+
   AllocationPage *next = page->_next;
   if (next != nullptr) {
     delete_page(next);