Hi all,
I have been using discord.tcl (
https://github.com/Unknown008/discord.tcl) (forked from
https://github.com/qwename/discord.tcl) for a while now and since the original author dropped the project, I have been passing some edits to the code, and most of it is working well. The yesterday it came to my attention that the bot was using a bit too much RAM (64 MB) and I started thinking about ways to bring memory usage down.
One of the things I believe is part of that problem is the huge dictionaries that are kept in memory. I believe the biggest one has a key for each server ID and the value is another dictionary containing things such as server name, server owner name and ID, members and each of these member's info, in brief, it's pretty big (my test discord bot is in 2 servers and the dict is slightly over 12k long characters (sorry I'm not good at performance related things so maybe I'm off the mark here)). That dict's name is [set ${::session}::guilds] (usually $::discord::session::0::guilds) and there are a few other similar dicts, one for users, one for channels and one for dmChannels (latter two are not as big).
My live bot is currently in about 6 servers with a larger number of users than my test bot and I'm still adding more "features" to the bot.
I'm thinking of changing the source code to put these data into an sqlite3 database and query it each time I need the data, but it's going to take me some time and I haven't settled on its structure yet. In the meantime, I would like a second opinion on whether I'm on the right track or not, or how I can do it better, or let me know if I can provide some information that would help you understand my issue better.
Or maybe the main issue is elsewhere, with the large pool of procs that have been defined or with the event listeners? Is there even any way I could improve the memory usage there?
PS: The actual script that uses discord.tcl can be found here:
https://github.com/Unknown008/MarshtompBot
Thanks,
Jerry