GregTech6 / gregtech6

This is the Official Repository of the Mod GregTech 6 for Minecraft 1.7.10
https://gregtech.mechaenetia.com
Other
188 stars 53 forks source link

Possible memory leak in PrefixBlock #86

Closed embeddedt closed 2 years ago

embeddedt commented 2 years ago

I'm tracking down the elusive dimension-changing memory leak in 1.7.10. One potential leak I've found is that PrefixBlock contains an mRenderParameterTileEntity variable, but it doesn't appear that this variable is cleared when the client world changes. This means that a block could potentially hold on to that client world until it is rendered again in another world.

I see two ways of fixing this: use a WeakReference to hold the tile entity (which will allow the world to be garbage collected), or loop through all PrefixBlock instances when the player changes dimensions and reset this field to null.

GC root diagram on an otherwise-unused WorldClient instance from VisualVM: image

GregoriusT commented 2 years ago

Yeah that one was a "what the fuck did I think back then" moment, lol

embeddedt commented 2 years ago

I haven't seen any leak issues when running the newer GT snapshot; thanks.