[1.16] Better Foliage Memory Leak
CorgiTaco opened this issue ยท 3 comments
Better Foliage version: BetterFoliage-2.6.4-Forge-1.16.5
Hi, I was playing with a handful of mods last night and was experiencing memory/GC lag so i decided to fire up visualvm and create a heap dump(after forcing a dozen GCs) and I discovered that Better Foliage had created a heap of 1.2gbs in the ChunkOverLayManager in a 40 minute playing session in creative mode flying around
Here's the evidence that drew me to that conclusion:
Here's the heap dump: https://www.mediafire.com/file/f5ui41ttya631or/betterfoliageleak.zip/file (requires visualvm to open)
Here's the latest log:
latest.log
Here's the debug log:
debug.log
I had some time to debug this issue, and I can see no memory leak. Handlers get called fine, arrays are dropped as chunks are unloaded, and memory usage remains more or less constant, even when vigorously flying around :/
Possibly some kind of harmful mod interaction? Dunno.
Nevertheless, the current implementation with arrays is a bit janky, and since I expect this data to be extremely sparse, I'm switching to Maps in the next release. Fingers crossed...
If you look at my duplicate issue (#358), I only have OptiFine_HD_U_G8, BetterFoliage and KotlinForForge installed. Because of this I'd guess it's an issue with OptiFine, I've got a lot of experience debugging OptiFine and would be happy to help find the cause of this.
Good catch, thanks. I was focusing on obvious/gamebreaking bugs, so this kinda slipped in under the radar.
The ChunkOverlayManager stores temp data for chunks (right now only round log neighbor connectivity), and my guess is the unload chunk event is not caught properly, so if you move around a lot with round logs enabled, these pile up fast.
I had some time to debug this issue, and I can see no memory leak. Handlers get called fine, arrays are dropped as chunks are unloaded, and memory usage remains more or less constant, even when vigorously flying around :/
Possibly some kind of harmful mod interaction? Dunno.
Nevertheless, the current implementation with arrays is a bit janky, and since I expect this data to be extremely sparse, I'm switching to Maps in the next release. Fingers crossed...