Fix: Node memory leak on small VPS
Symptom
Node.js process memory usage keeps growing until the VPS crashes or the process is killed.
Cause
Insufficient memory on small VPS combined with lack of memory limits or garbage collection tuning.
Solution
- Increase swap memory.
- Set a memory limit for Node.js.
- Restart the process using a process manager.
Configuration
NODE_OPTIONS="--max-old-space-size=256"
Verify
Monitor memory usage with htop or free -m.
Expected result:
Stable memory usage without crashes.
Notes
Use PM2 or systemd to auto-restart the process.
- This fix is part of Fix Pack – Ghost behind Nginx.
Get all fixes in one place:
https://diorama0.gumroad.com/l/ptrzok