Memory Leak NodeJS

Hi! Our server has some memory leakage that we can't catch locally. Would like to save the dump of production and then analyze it. But you don't have any way to download the heapdump file How we could catch our production memory leakage?
12 Replies
Percy
Percy11mo ago
Project ID: N/A
jeremy
jeremy11mo ago
You could upload the output file from the heapdump into S3/R2, whatnot
0xkavango
0xkavango11mo ago
How to upload? With application itself? ServiceID = 7e617622-11d1-46f0-b104-7884c8728782
jeremy
jeremy11mo ago
How are you generating your heapdump file within node?
0xkavango
0xkavango11mo ago
v8.writeHeapSnapshot();
jeremy
jeremy11mo ago
you can specify a filename to writeHeapSnapshot which is the path where your file will be saved. From there, you can either use a buffer or a stream to read it, and use any third party library to upload your file to a storage service. You might already use some service for that
0xkavango
0xkavango11mo ago
so, application itself should upload it
jeremy
jeremy11mo ago
your node application, yes
0xkavango
0xkavango11mo ago
Thank you! One more question here. Looks like you keep all application's logs. Is their size included in application's memory metrics?
Brody
Brody11mo ago
Jeremy doesn't work for Railway, and neither do I, but I can confidently say that logs are absolutely not part of the memory metrics, but that's a fair question indeed
0xkavango
0xkavango11mo ago
Thank you Brody. I am just trying to figure out the issue
Brody
Brody11mo ago
could be due to different node versions? on railway node 18.17.1 is used by default id first try getting the environment railway is running your app in as close to the environment you can run locally, this means writing a Dockerfile for railway, making sure the memory error is still there on railway, then run the Dockerfile locally since it would be so much easier to profile the running image locally
Want results from more Discord servers?
Add your server