Closed MaPePeR closed 3 years ago
Does the config option in citadel.cfg not work?
Setting "Track Entities" = false
did indeed fix the memory leak. Not sure what's the other consequences of that are, though. I guess you do Entity-Tracking for a reason? Didn't expect to find a "don't memory leak"-option, so I didn't really look, to be honest.
A real fix would probably be to also store a WeakReference
in EntityProperties
? Since entity
is already private the subclasses should go through getEntity()
anyway, which could then resolve the WeakReference
. Subclasses would need to be aware of the possibility of getting null
from getEntity()
, though.
Edit: also didn't find any reference to the config in the code, so I assume the latest version is not uploaded here?
Got it, from 1.7.2 onwards entity will be a WeakReference.
ResourcefulBees' apiary breeder creates temporary entitys to do it's breeding. That can create a lot of Entitys. That wouldn't be as bad in itself, if Citadel wouldn't prevent the entitys from being garbage collected. See Resourceful-Bees/ResourcefulBees#266
This is one of the hard references of an![image](https://user-images.githubusercontent.com/527679/125187046-eb0f8280-e22d-11eb-847e-4dd7bfb4b497.png)
ResourcefulBee
:The
EntityDataHandler
creates aWeakIdentityHashMap<Entity, List<IEntityData<?>>>
, but theWeakIdentityHashMap
is only Weak-Referenced in its keys.EntityProperties
(implementingIEntityData
) and all subclasses keep a hard reference to theEntity
Object preventing it from being garbage collected causing a memory leak.