Fix multiple memory leaks and stale pooled allocations

* Fix Vec3/AABB pool reset logic

  * resetPool()/clearPool() now reset poolPointer to 0
  * Prevents endless pool growth, invalid temporary references,
    and increasing memory usage
  * Resolves the leaderboard-related crash mentioned in
    Windows64_Minecraft.cpp

* Properly free old screens in Minecraft::setScreen()

  * Added virtual destructor to Screen
  * Screen destructor now cleans up GuiParticles and Buttons
  * Previous screen is now deleted after screen transitions
  * Screen::init() now clears old buttons/particles before re-init

* Fix GuiParticles memory leak

  * Removed GuiParticle instances are now deleted in tick()
  * Added GuiParticles destructor to free remaining particles
This commit is contained in:
Zero
2026-05-26 16:08:09 +02:00
parent b595d0bb55
commit 5ccc8db088
7 changed files with 39 additions and 2 deletions

View File

@@ -47,10 +47,16 @@ Vec3 *Vec3::newPermanent(double x, double y, double z)
void Vec3::clearPool()
{
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if (tls != nullptr)
{
tls->poolPointer = 0;
}
}
void Vec3::resetPool()
{
clearPool();
}
Vec3 *Vec3::newTemp(double x, double y, double z)