From aef170d7e01896309bb195c1a593101af4be45f7 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 24 Mar 2017 21:45:27 -0400 Subject: [PATCH] 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. --- discord/state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/state.py b/discord/state.py index dc12d54ed..497fa130e 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 = {}