-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Referenced message entries exceed the max messages settings #904
Comments
Alright, so the problem was that Discord doesn't send second-level referenced_message. Meaning if we have B references to A and C references to B, B's referenced message will be None as opposed to A, thus leaving A's ref count to remain the same when garbage collecting. And since Discord provides you with the ID of the referenced message, this is what I do to get around currently https://github.com/norinorin/nokari/blob/31fd0078af81269204dd3370e932840c916cb03a/nokari/core/cache.py#L154-L162. I could make a PR if you'd like me to. Jump link to relevant messages: https://discord.com/channels/574921006817476608/700378161526997003/910704551131246663 |
Steps to reproduce
There's no steps but to run the bot as usual.Send a message, let's say it's message A. Then, reply to message A, this reply is message B. And finally, reply to message B.Expected result
Message B has the referenced_message attribute set to A.Cache.get_messages_view()
returns a bit more than n messages if not exact, where n is the max messages we put in the config.Actual result
It returns a lot more messages than it should. Turned out,Message B has the referenced_message attribute set to None. This would lead to a memory leak if people were to reply a lot as it would leave some referenced messages untouched when garbage collecting.Cache._referenced_messages
seems to be caching messages that should've been GC'd as they're no longer referenced.System info
hikari (2.0.0.dev104) [HEAD] located at /home/nori/.local/lib/python3.9/site-packages/hikari CPython 3.9.7 GCC 11.1.0 Linux arch 5.14.16-zen1-1-zen #1 ZEN SMP PREEMPT Tue, 02 Nov 2021 22:23:00 +0000 x86_64
Further info
Might be somewhat relevant to #877 and perhaps #894 if we were to hide referenced messages?
Checklist
The text was updated successfully, but these errors were encountered: