-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Potential memory leak from EnvPlayer #590
Comments
Implementing that change and noticing opponents need their battles reset too seems to have fixed the |
Great work! Out of curiosity, which tool did you use to monitor garbage collection and detect this? |
I used Pympler in a training callback that monitored changes in memory through the number of existing objects. I noticed the number of battles kept increasing each iteration even though I modified the code to delete them and manually called the garbage collector. So I knew a reference to them had to be hanging around somewhere. After looking through the code, I found that However, the performance degradation over time others have noticed still exists. I'm still debugging that one. I'm not sure if it's a poke-env, showdown, or stablebaselines3 issue. I'll be sure to put up an issue if I narrow it down. |
There seem to be several memory leaks as matches pile up. But one area that is causing some of it appears to be
_reward_buffer
inEnvPlayer
. It holds references toAbstractBattles
and doesn't ever release them. An easy solution is to swap its initialization toweakref.WeakKeyDictionary
. That will allow the keys/Battles to not have their garbage collection be blocked by the_reward_buffer
. If the battles are deleted elsewhere, they'll be dropped from the dict automatically. I'm still testing and looking for other areas that could be causing the memory leaks.The text was updated successfully, but these errors were encountered: