FoamyExtendedBlockState minecraft:water Memory Leak (client only)
KaktuszSok opened this issue · 2 comments
Hey, 2 of the last 3 custom modpacks I ran on my server had consistent memory leak issues for all players, meaning they had to restart the game every few hours or, in more complex areas, every hour or even more often. The issue happens regardless of any of the JVM arguments we tried as well as when using OpenJ9.
I took the following steps to try and track down the problem:
- Launched the modpack with 8GB RAM (also happens with less, i.e. 6GB) and logged in to a singleplayer world
- Left the game on overnight (much longer than needed to reproduce this issue)
- After returning, the game was frozen as the GC could not manage to free up enough space for new objects.
- Opened VisualVM and took a heapdump of the game at this point.
- Compared it to a heapdump I took of the game fresh after logging in to a world, where the memory usage was 3.2GB after a GC and went up to about 4.5GB.
Here is the heapdump when the game is overfilled:
As can be seen in "Classes by Size of Instances", com.google.common.collect.SingletonImmutableBiMap and pl.asie.foamfix.common.FoamyExtendedBlockState are taking up ~1.5GB each. In the freshly loaded game heapdump, they only take about 600MB each.
Looking into these instances, they all seem to be block states for minecraft:water, and the SingletonImmutableBiMap instances are all key-value pairs where the key is "level" and the value is the water level.
The issue happens after AFKing on a superflat world too. Quitting to menu does not fix it, a full game restart is required.
This is likely a mod compat issue. I couldn't figure out which mod in particular causes this but it doesn't happen when foamfix is not installed. The only mods that were in both modpacks that had this issue but not in the one that didn't were: MovingQuickly, bettercaves, EnderStorage and OpenComputers. Removing MovingQuickly did not get rid of the leak. It might be bettercaves but it makes no sense that the leak is present on client and not on server. We have no EnderStorage or OpenComputers blocks placed in our world. This leads me to believe it may be caused by one of the many other mods provided in the modlist below. Any tips on making finding said mod easier are appreciated.
Mod list: https://pastebin.com/me9v1hSn
Log:
2021-03-15-1.log
The memory leak seems to have been caused by a concerning - performance-wise, at least - design decision in Railcraft, however it is an issue specific to FoamFix. It has been fixed in 0.10.12.