Cold Sweat

Cold Sweat

5M Downloads

[BUG] Client Side Memory Leak

linstarowo opened this issue ยท 1 comments

commented

Disc

The "HearthBlockEntity" will register itself to the forge event bus when it is initialized. This causes the instance not to be cleared when the world is closed, because it is still referenced by the forge eventbus. It is not matter in server side because the server will create level instances only once. However, the client will do it each time changing dimension. Blockentites that cannot be uninstalled reference an old ClientLevel instance, the old ClientLevel instance reference some RemotePlayer instances. Now they all cannot be cleared by GC. The hanging RemotePlayer instances also influenced the TemperCapCache, the entry of these player entity will not be cleared because they have a strong reference.

Info

here are some infomation the MAT shows

Image Image Image
commented

This is a good catch. It looks like the setRemoved() method, which is responsible for un-subscribing the block entity from the Forge event bus, is not called on the client side, leading to the buildup of old objects you're seeing here. I'm pretty sure I've found a solution that properly deregisters the block entities when the chunk or level is unloaded.

Thanks for the detailed report :)