#Is there a command to clear all the manager caches?

1 messages · Page 1 of 1 (latest)

hard cloud
#

Why would you do that at all?

summer torrent
#

Since my bot is running on several hundred servers the cache gets very full and nightly reports will not work correctly since I hit the RAM limit.

#

But the report always seems to work after a fresh startup.

#

Besides paying more for a virtual machine with more RAM do you have any other ideas?

hard cloud
#

You can fix it using cache.clear() most likely

#

But it looks like a Discord.js problem here, as cache should be freed during low free ram

#

@rain inlet's answer is somewhat good too, but I'm pretty sure that object is used somewhere else too, and it will break stuff. Mine should be fine

summer torrent
#

I'll check it out.

#

I tried limiting the cashes but it definitely broke stuff.

rain inlet
#

yep yours seems a safer way xD

summer torrent
#

I figure if I clear it out it should rebuild itself.

#

Is it necessary to call .clear on each cache?

rain inlet
#

why would you manually empty your cache tho

hard cloud
#

@rain inlet since you're a sponsor can you summon a dev?

#

Cache should be freed on low ram automatically

rain inlet
summer torrent
#

At least this is my guess since I see memory usage spiking.

rain inlet
#

have you tried limiting your caches?

summer torrent
#

And the report runs perfectly fine after a fresh launch of my app.

hard cloud
#

What is this report all about?

summer torrent
#

I tried limiting some of them, but I must have limited too much and crashed the app.

hard cloud
summer torrent
#

Here are the different caches I was looking at:

hard cloud
#

You should almost never use cache.get

next violet
#

That is absolutely untrue

#

Spread nonsense elsewhere

glass ruin
#

@summer torrent i think you may just need to go through each single cache collection and use collection.clear() im not sure tho so dont take my word for it

rain inlet
#

if you really want to clear all those caches yeah you'd have to go through every single one of them there's no method that clears all of them

summer torrent
hard cloud
summer torrent
#

Those I believe are all the caches. I wish I could find recommended settings for them.

summer torrent
hard cloud
summer torrent
#

Take for example the MessageManager cache. Does each server that installs my bot have their own message cache?

#

Or is this one cache for all servers?

rain inlet
#

for all servers

hard cloud
#

I'm not sure, but maybe client.guilds.cache.clear() may be enough

#

The GC will take care of the rest

summer torrent
#

Got it.

#

I'll give that a shot.

#

I'm not too familiar with the cache so I appreciate the input.

#

Learning as I go on this one.

rain inlet
#

yeah each channel object has a messagemanager

#

which then has the cache

summer torrent
#

eek...so I would have to clear the cache from every channel that my app can see?

rain inlet
#

yes yikes

summer torrent
#

oh boy...maybe I would look into limiting that cache instead lol

#

I'll have to see if I can find more details on limiting caches.

rain inlet
#
client.channels.cache.forEach(c => {
    if (c.isText()) {
        c.messages.cache.clear()
    }
})```
#

you'd have to do smth like this 💀

summer torrent
#

Suppose my app can see hundreds of channels, maybe thousands...lol

rain inlet
#

200*<ChannelManager>.cache.size() is your amount of cached message objects

#

then just think about it... do you really need to have these messages cached?

summer torrent
#

Right

rain inlet
#

I have it set to 20 per channel shrug but idk what your bot does so

summer torrent
#

That's might be the cache to go after first. Seems like that one could bloat quickly.

rain inlet
#

yesyes

#

and disable the ones you'll never access

#

like idk

#

StageInstanceManager

summer torrent
#

Sounds good! I'll play with it and see what happens! Thanks for your help and thoughts!

rain inlet
#

yep np

#

good luck