0

I am hosting a NodeJS app on a Ubuntu server. The server has 512 MB of RAM and is pretty basic since I am the only user of the app.

Recently, the app ended exited with the following errors:

npm ERR! code ELIFECYCLE
npm 
ERR! errno 137

I looked up this error and it is due to lack of memory. I have now rebooted my server and restarted the app again. I ran the free -m command to see what my memory usage looks like. Here it is:

              total        used        free      shared  buff/cache   available
Mem:            475         239          27           0         208         219
Swap:             0           0           0

I am wondering if this a memory leak in my app or due to the server just being tight on memory with only 512 MB. I thought 512 MB would be enough since its basically not getting more than 1 request at a time (me).

Further, I am running my app using pm2 so is there a way to notify myself if the app exits again like this abnormally?

Thank you in advance for any solutions!

philosopher
  • 111
  • 2
  • Try checking `dmesg`. It does look like it might have been killed because it was using too much memory. You could try running it in an environment with more memory and check how much it is using in normal operation. If it keeps climbing for no reason, you might have a memory leak. But if it's just using more than available on the server, it's just not enough ram. – rudib Dec 01 '20 at 12:51
  • Also see: https://unix.stackexchange.com/questions/36450/how-can-i-find-a-memory-leak-of-a-running-process – rudib Dec 01 '20 at 12:59
  • Thanks. So far after running the app for 1 hr, the memory usage looks steady, I will check again tomorrow after 24 hours. I did try `dmesg` but there's waaay too much on there, any particular keyword to look for? – philosopher Dec 01 '20 at 13:38
  • I think it might be `oom_reaper`. But it might be called something else on Ubuntu server. But I'm not sure if this *has* to be a memory issue (at least as long there is no evidence in `dmesg`) – rudib Dec 01 '20 at 14:39

0 Answers0