From d65e46e7b72964abffec7333134c29d318290c5f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 4 Sep 2025 14:05:29 +0200 Subject: [PATCH] pgraph: Track CullableObject memory usage --- panda/src/pgraph/cullResult.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 0caa7231a7..eb8d3519d2 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/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);