-
Notifications
You must be signed in to change notification settings - Fork 501
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 for memory leakages in SteamDB #292
Conversation
That's why I prefer using There will still be leak if Steam decides to push us new list of servers before actually disconnecting, as our current I'd be up for using |
True. Odd edge case, but definitely worth considering.
Probably. It does mean that we could still end up with stale data, but at least memory won't balloon indefinitely.
I'm not expecting subsequent ServerList messages to contain less server types. Even if it does, the memory should be relatively negligible. I'll switch it over to |
That's true, but considering steam maintenances and everything what is happening, our data can still be cleared on disconnect and recent enough to satisfy us. I doubt that any bot can handle being truly online without a disconnect for more than a few days anyway, so that
Good job on this PR, I was wondering why my |
I might have to think about this a little more... ideally you should get no servers back when disconnected, but I don't want to thrash memory on object creation/GC. |
HashSet supports advanced collection-like functions, including
Old servers are direct copy of what we have in After such thing, It solves problem of stale data, yet avoids recreating set from nothing. I'm using similar trick for updating my MySQL database to avoid fragmentation - In database I have set A, currently I have set B, and the objective is to remove from A what doesn't exist in B, and add to A what exists in B only, but not in A already. Recreating entire thing is easier, but I actually store gameIDs, so fragmentation would kill me for users with 2k+ games. It's more efficient to do calculation and push only "changes" instead of entire data. Not to mention that write operation is expensive in my case considering write lock is acquired, so the less data to write - the better. |
I don't think the issue is the
Looking at the extremes, if the
On the flip side, if the hashset contains all new servers exactly, then:
So it would appear that no matter what we do, N(newservers) objects will be allocated, and typically most or all will be GC'ed. So I don't think we can do anything about the amount of What we could do is flip back to the original method, but retain the Am I making sense? |
Definitely it does make sense to me, it's all based on what goals you want to set for SK2 as a maintainer. I'd still suggest to keep
So indeed, I think that original method with |
…ap values when disconnecting.
serverMap
was never being cleared, so re-using the sameSteamClient
object when reconnecting to Steam caused memory to balloon.ServerListCallback
. If only running callbacks periodically, e.g. every tick of an application, it will take N ticks to clear a queue of N callbacks. I've added an API to run all pending callbacks, which should fix this issue.