Cooking for Blockheads

Cooking for Blockheads

145M Downloads

Memory leak in LowerableFacingOnDemandModel

bothie opened this issue ยท 1 comments

commented

After AFKing over night, my FTB client was fully unresponsive, looking at the console, I figured out immediatelly, that the game spent pretty much 100% of it's time in GC. I created a heap dump using "jcmd PID GC.heap_dump" and opened it in visualvm, looked for the top 20 retained size objects and found ...

net.blay09.mods.cookingforblockheads.client.LowerableFacingOnDemandModel

having a retained size of 2.3 GB (no, not an error, actually 2.3 GB).

mc-ftb-cookingforblockheads-memory-leak

With an overall memory foot print of 4GB, 2.3GB for a cache(!) is way too much.

Looking at the code, the problem is obvious: You forgot to add a way to remove items from the cache, so, it gets bigger and bigger the longer the game runs until it causes the game to run out of memory.

commented

Thanks for spotting this one and going through the efforts of profiling.

The real problem was that the cache was using a wrong key, so it kept creating new models for the same thing whenever a chunk with any of them was rebuilt. Removal isn't necessary here since even at full size it won't be anywhere near problematic, and the on-demand-caching is just for speeding up load time (and reducing unused memory waste).