From b17fe835bc49a90b6b86d1b30da423d6ea875b60 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 29 Feb 2024 13:42:22 +0000 Subject: [PATCH] Hardware meshbuffers are now deleted when they hold the last reference to a meshbuffer HW buffers were keeping meshbuffers alive for 20000 frames even when no one else was using them anymore. In cases of rapid creating/destroying static meshbuffers this could lead to serious memory leaks (which then kinda topped out after 5 minutes, but at that point it could already be too late). git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6599 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + source/Irrlicht/CNullDriver.cpp | 2 +- tests/tests-last-passed-at.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/changes.txt b/changes.txt index 049d6d13..85616d0a 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Hardware meshbuffers are now deleted when they hold the last reference to a meshbuffer - Variable order inside SMaterial and SMaterialLayer changed for better packing - line3d::getClosestPoint can now chose between using line or line segment - MY3D loader deprecated and disabled by default as MY3D tools can't be found on the web anymore. Also could always be used as external loader. diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index dbb9dcfb..20adcff4 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1815,7 +1815,7 @@ void CNullDriver::updateAllHardwareBuffers() SHWBufferLink *Link=Iterator.getNode()->getValue(); Link->LastUsed++; - if (Link->LastUsed>20000) + if (Link->LastUsed>20000 || Link->MeshBuffer->getReferenceCount() == 1) { deleteHardwareBuffer(Link); diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index e0b69f88..1697fe69 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Thu Feb 22 17:49:13 2024 +Test suite pass at GMT Thu Feb 29 13:39:39 2024