aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-03-24 21:45:27 -0400
committerRapptz <[email protected]>2017-03-24 21:46:32 -0400
commitaef170d7e01896309bb195c1a593101af4be45f7 (patch)
tree458d412f2ba10bb9231a9962bc6bb242660c8071
parentRevert "Reference the ConnectionState by weakref." (diff)
downloaddiscord.py-aef170d7e01896309bb195c1a593101af4be45f7.tar.xz
discord.py-aef170d7e01896309bb195c1a593101af4be45f7.zip
Fix memory leak by holding on to Emoji references weakly.
The library had a memory leak in the case using the global emoji cache. When the bot would leave the guild, the Emoji would maintain a strong reference to the Guild keeping them alive along with the entire state associated with it.
-rw-r--r--discord/state.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/discord/state.py b/discord/state.py
index dc12d54e..497fa130 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -70,8 +70,8 @@ class ConnectionState:
def clear(self):
self.user = None
self._users = weakref.WeakValueDictionary()
+ self._emojis = weakref.WeakValueDictionary()
self._calls = {}
- self._emojis = {}
self._guilds = {}
self._voice_clients = {}
self._private_channels = {}