#V14 Bot is using more RAM compare to v13

41 messages · Page 1 of 1 (latest)

vestal arch
#

After migrating from v13 to v14, my bot is using 100% of available RAM in server. It use approx 500MB RAM for 3 guilds and increase over time.

Some details.
Bot stats: 1100 Guilds, 902795 Cached Members
System Info: Ubuntu, 4 GB RAM
Intents: Guilds, GuildMembers, GuildMessages, MessageContent, GuildMessageReactions, GuildEmojisAndStickers

tepid sorrelBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

vagrant coyote
#

And what does your bot do exactly? What does it cache, what did it cache on v13, …?

vestal arch
#

It cache same things in v13 too

vagrant coyote
#

What same things?

vestal arch
#

Guilds, Channels, Members, Messages and Emoji

vagrant coyote
#

A million members are a lot of data to begin with

vestal arch
#

V13 client is using only 921.77MB with same data

vagrant coyote
#

Can you show your full client constructor please? And do you utilize sharding?

vestal arch
#

I haven't added sharding

#

give me a moment, let me create a gist

vagrant coyote
#

That doesn’t tell me much because I‘m more interested in what you actually pass as options when instantiating your Client

vestal arch
#
let bot = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMessageReactions,
        GatewayIntentBits.GuildEmojisAndStickers
    ],
    failIfNotExists: false
});```
vagrant coyote
#

Why is that a let, do you reassign that later?

vestal arch
#

No, sometimes i use let instead of const becuase of habit 😅

vagrant coyote
#

RAM usage increasing over time is normal and definitely happened on v13 too if you had only those options in client constructor. Because you cache up to 200 messages per TextBasedChannel your bot can see.

vestal arch
#

But it is using all RAM in half and hour

#

Here us the vps graph

#

the stable line is for v13 version

vagrant coyote
#

And how much did it use when you had it on v13? Because 1100 guilds with 1M GuildMember/User values and 200 Messages per Channel, plus emojis, stickers, Reactions, permissionOverwrites adds up

vagrant coyote
vestal arch
#

It is using RAM too

#

i cant find RAM graph in aws

vestal arch
vagrant coyote
#

With same intents? And no makeCache or sweepers settings?

#

Same bot token?

vestal arch
#

Yeah

#

it uses default settings of discord.js for managing the cache

vagrant coyote
#

Doubt because not all of those intents exist in v13…

vestal arch
#
let bot = new Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MEMBERS,
        Intents.FLAGS.GUILD_MESSAGES,
        Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
        Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS
    ],
    failIfNotExists: false
});```
#

v13 client constructor

#

The only intent i have added is message_content which is required by gateway

vagrant coyote
#

You can try to find what leaks memory, I doubt it‘s djs but if you. can prove it is we‘re happy to accept PRs to fix it

#

Probably something else you changed when moving to v14 code

vestal arch
#

How can i find memory leak 😅

#

its a new thing

vagrant coyote
vestal arch
#

Thanks

vagrant coyote
#

That’s for general ideas… to actually find them use Google Chrome tools to make memory snapshots to compare