memory leak

I don’t know but for some reason there’s so much memory that is allocated but can’t or doesn’t need to be used by current node heap
36 Replies
Percy
Percy11mo ago
Project ID: N/A
ImRopoxPro
ImRopoxProOP11mo ago
No description
ImRopoxPro
ImRopoxProOP11mo ago
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
ImRopoxPro
ImRopoxProOP11mo ago
No description
ImRopoxPro
ImRopoxProOP11mo ago
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
ImRopoxPro
ImRopoxProOP11mo ago
No description
Fragly
Fragly11mo ago
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
dan
dan11mo ago
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 :)
Brody
Brody11mo ago
thank you dan, very well said!!
ImRopoxPro
ImRopoxProOP11mo ago
I didn’t say railway stats were lying Just wondered why I got multiple result I’m using discord.js and I checked the cache customization docs, also set up sweepers for the client
dan
dan11mo ago
Sweepers are just one part. I'd recommend going through your code thoroughly and analyzing it
ImRopoxPro
ImRopoxProOP11mo ago
Dude it’s so hard to find the cause
dan
dan11mo ago
Last time I had a memory leak it was because of a deprecated function I forgot I had Debug
ImRopoxPro
ImRopoxProOP11mo ago
Debug what Heap snapshots don’t reveal anything I don’t know what is taking so much memory
dan
dan11mo ago
Are you testing on your local machine?
ImRopoxPro
ImRopoxProOP11mo ago
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
dan
dan11mo ago
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
ImRopoxPro
ImRopoxProOP11mo ago
Like this
No description
ImRopoxPro
ImRopoxProOP11mo ago
Very slowly I’ll have to review my handler logic I guess
dan
dan11mo ago
I can't help much from here, but just try to mess around with stuff and determine the root cause
ImRopoxPro
ImRopoxProOP11mo ago
Interesting, locally running my health check command looks a lot different
ImRopoxPro
ImRopoxProOP11mo ago
No description
ImRopoxPro
ImRopoxProOP11mo ago
There’s a lot of memory allocated but not used by heap thonk
ImRopoxPro
ImRopoxProOP11mo ago
Stack Overflow
Memory usage doesn't decrease in node.js? What's going on?
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
ImRopoxPro
ImRopoxProOP11mo ago
Can this comment be correct?
Brody
Brody11mo ago
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
ImRopoxPro
ImRopoxProOP11mo ago
How is is out of scope I’m trying to find the cause or find a reason
Brody
Brody11mo ago
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
dan
dan11mo ago
+ 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
Brody
Brody11mo ago
again, beautifully said
dan
dan11mo ago
Thank you lol. I personally think the way i word sentences is horrible 😭
Brody
Brody11mo ago
no way it's perfect, both firm and caring
ImRopoxPro
ImRopoxProOP11mo ago
no one can help there’s only you
Brody
Brody11mo ago
im sorry, but coding help is out of scope
ImRopoxPro
ImRopoxProOP11mo ago
Thanks for the info tho so pls ban me
Brody
Brody11mo ago
why would you get a ban??
Want results from more Discord servers?
Add your server