Why is my Node.js app using so much memory after a few days?

michelle27 AU 🔍 Enthusiast 👁 48 ⚑ Report Programming

I've got a Node.js backend running on a DigitalOcean droplet that handles webhook processing. After running for a few days, memory usage creeps up to like 80-90% and I have to restart it. There's no obvious memory leak in my code that I can see. Should I be looking at the event loop or is this something with how Node handles garbage collection?

1 answer

Check your webhook handlers first - unterminated connections, accumulated objects in closures, or buffers that aren't being released are the usual culprits, way more common than garbage collection issues. Use something like clinic.js or the built-in heap snapshots to see what's actually sticking around in memory instead of guessing. The event loop itself rarely causes memory bloat; it's almost always objects that never get cleaned up. If nothing obvious shows up in your code, look at your dependencies - sometimes a library caches things aggressively or has a bug that was fixed in a newer version.

Your answer

Log into answer.