-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tree felling helper memory leak #2677
Fix tree felling helper memory leak #2677
Conversation
wouldn't using an iterator explicitly and using it's remove method be better then making a 2nd set? |
It does make more sense to use the iterator in this context, I keep forgetting that they let you remove an element while iterating |
Also it makes no sense that helpers is a set if they are added in the constructor - this class has no hashCode() or equals() method - so each object is unique - so the set will never fail to insert - but perform a lot of useless operations. using an ArrayList would be better. |
Onion moment |
imo now that the memory leak is gone the performance impact of the collection shouldn't matter unless you have 1000's of players chopping trees permanently with the fastest chainsaws they can find. |
linked list is possible the worst possible list to use in any case - it has the highest memory allocation overhead - and the slowest iteration. |
yeah, I was mostly messing with you, using a linkedlist is triggering people |
What
Previously we would allocate helpers but never release them, moreover we would iterate over all finished ones every level tick.
Implementation Details
Just added a set to collect the inactive helpers each iteration to remove them at the end.
Outcome
Players cannot bring down servers by chopping too many trees.