Skip to content
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

Unneccesary memory usage in Message.js #1247

Open
curtisf opened this issue Jul 15, 2021 · 1 comment
Open

Unneccesary memory usage in Message.js #1247

curtisf opened this issue Jul 15, 2021 · 1 comment

Comments

@curtisf
Copy link
Contributor

curtisf commented Jul 15, 2021

In the update function for Message.js, a few properties (embeds, mentions, components for example) are set if the appropriate payload contains them. Even though they are marked as optional in the Discord API docs, I see them passed with every MESSAGE_CREATE. The purpose of this issue isn't to argue whether these properties are passed every time but to bring to light the fact that many of the properties in Message are passed as empty arrays. Eris only checks for !== undefined, which means for many instances of Message, there are unnecessary empty arrays being assigned. As a consequence, more memory is used per message which could negatively affect users who cache any large amount of messages in memory.

@Dramex
Copy link
Contributor

Dramex commented Jul 25, 2021

These empty arrays actually aren't stored in your cache, they are getters comes from Message class to force style of code
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants