Dynamic Surroundings

Dynamic Surroundings

51M Downloads

Clear ParticleCollections on WorldEvent.Unload (if WorldClient)

asiekierka opened this issue ยท 7 comments

commented

Just so the WorldClient reference is dropped a bit earlier and not as much memory remains in use.

Also, I'm seeing a lot of MoteWaterSprays remaining for a long-unloaded overworld. Not sure why.

Also, is it just me, or will this always return true, as it is not the WeakReference's contents which are checked for null, but the reference itself (which is never null)?

In general, I'm looking into the long-lasting modded issue of WorldClient memory leaks, and your mod seems to be one of the mods implicated in this. If you need more help, I can look into it deeper.

commented

Made a test jar with some code to clear the particle collections on world unload. This should do the trick. Can you take a peek to make sure things are inline with what you would expect?

commented

This fixed the very particular issue of ParticleCollections being kept. However, I'm not sure if the mod doesn't have further issues relating to WorldClient leaks - I lack proper tooling which makes debugging this take a long time... Nonetheless, thank you!

commented

No worries. It's on my list of things to review other areas of the mod that have static data. Most of the data is held in handlers, and those get wiped on disconnect.

commented

Thanks for the info! I will look into the WorldUnload - makes sense to me. The water spray one has me a little baffled for the moment. I will have to dig into it.

As for the reference you point out it can return false. The logic is a bit convoluted. The logic on line 137 sets "c" to a chunk reference or null. If it is null it then sets a member variable to NULL_CHUNK, but "c" remains null. So when execution falls out the bottom of the function it could return false. At least that is the way I intended and reads to me after a single cup of coffee. :D

commented

Oh, sorry, it is just me! That's alright then.

commented

Yeah - I think its the motes holding onto world references. The collection itself queues as a particle into the Minecraft particle manager. If the particle manager just orphans that reference the collection still hangs around. And since the motes hold onto world references things just linger.

commented

Pushed v3.4.9.4 to CurseForge.