NodeJS memory leak
I have a service running some cron jobs. It takes some things from postgres using prisma, it updates some other things in there and does some api calls to another service.
The issue is it recklessly eats memory.
I profiled it locally for over 12h and can't find a memory leak. It stays within 50mb heap when it runs locally.
I tried removing parts of the code and couldn't find anything obvious so in the end I decided to simply limit nodejs.
If it goes over 128mb it should crash.
"start:refresher": "node --max-old-space-size=128 dist/index",
Even after doing this, memory usage keeps increasing and node doesn't crash, so I suspect it is not caused by node.
I hope someone can help me debug this.7 Replies
Project ID:
e41291cb-5971-4358-80ec-809d64899894
It appears that the source of the problem was found to be a session cookie that was set to expire after 8640000 milliseconds.
⚠️ experimental feature
e41291cb-5971-4358-80ec-809d64899894
the issue is visible in the
refresher
service in all my environments, but more so in production
and staging
because those have been running for a while. I restart the dev
environment often and memory usage gets reset.
This got better after I disabled winston logger console transport...
So...lots of console messages increase memory usage?@andreiv.eth did you ever figure this out? I have a similar problem with a python project and I can't spot the issue in the code.
this was about node lol
Yeah, I get that
Their conclusion was that saving large amounts of logs was causing their app to use more memory
it’s very likely yours is a different issue. Please create your own help post and provide more information