#memory leak
52 messages · Page 1 of 1 (latest)
Project ID: N/A
And I see an increase of memory usage day by day, and when I try to take heap snapshots, it just is 58MB
Heap snapshot can’t find the other missing 230MB of the memory
there's several values here, actual memory usage is around 260MB, which is not acceptable for a simple discord bot, and the heap snapshot did only take 58MB of memory data
Keep in mind that memory may be allocated while not being included in the heap
your app's architecture plays a big role in the memory allocated vs memory used
Railway's metrics are accurate and won't lie about your app's resource usage
I'd recommend learning about what kinds of things could cause more memory allocation
and then investigate that within your app
Adding onto what fragly said, I can assure you that railway doesn't lie about metrics. Your bot's high memory usage may be due to caching or other unoptimized structures that are hogging your memory. I'd recommend taking a look at everything, including sweepers. Not sure what library you're working with but they are really important regardless. Memory leaks happen for a reason, so you should always do more investigating (including on your local machine) before jumping into conclusions.
This is just a piece of advice as I used to have similar issues in the past :)
thank you dan, very well said!!
I’m using discord.js and I checked the cache customization docs, also set up sweepers for the client
Sweepers are just one part. I'd recommend going through your code thoroughly and analyzing it
Dude it’s so hard to find the cause
Last time I had a memory leak it was because of a deprecated function I forgot I had
Debug
Debug what
Heap snapshots don’t reveal anything
I don’t know what is taking so much memory
Are you testing on your local machine?
Uhhh I didn’t run my code enough locally to cause memory leak ig
I saw it on railway graphs
Like see an actual leak
I happens day by day or week by week
Then do that. It is way easier to debug something on your local machine compared to railway. Mess around with the bot, have task manager open and monitor the increase in system usage
Personally, I find memory leaks by enabling/disabling parts of my code that rely on memory. It might not be the best way but it works for me
I’ll have to review my handler logic I guess
I can't help much from here, but just try to mess around with stuff and determine the root cause
Interesting, locally running my health check command looks a lot different
There’s a lot of memory allocated but not used by heap 
I am tracking the memory using task manager and my app is a webrtc app using socket.io.
So when I track the memory and open localhost, connect two browser windows, it obviously adds a little bit of
Can this comment be correct?
I'm really sorry but coding help is a bit out of scope of these threads, but Dan and fragly have already helped tremendously, please take their advice
right but the cause or the reason will not have anything to do with railway
unfortunately we just can't offer programming help as these are forums for platform help
- It should not be us telling you what to code, how to code it, etc. Not that it's bad thing, help is always good, but nobody here is familiar with your infrastructure besides you, and our input can possibly worsen things because we don't know the core of your project
again, beautifully said
Thank you lol. I personally think the way i word sentences is horrible 😭
no way it's perfect, both firm and caring
im sorry, but coding help is out of scope