I used Nuxt.js to build my blog application, deployed in linux, the memory used is too high.
My server using ubuntu operating system, 1g memory, I use pm2 persistent node application.
I deploy my project every time, you can see the memory is normal, about 80m or so,
After a period of time, the memory will soar to more than 500m, the final memory overflow, resulting in server crashes,
When I found that memory usage up to 90% of the time, I kill off the nuxt process, pm2 immediately restart it, then returned to normal
I am curious, why is my memory usage going up all the time?
Here is the screenshot
Abnormal state
normal status
My solution is set the max_memory_restart: "160M" attribute to ecosystem.config.js for pm2, the pm2 will listen the app memory, it will auto restart the app when the memory beyonds 160m, it can works, but it's not right solution.
I get the document from Nuxt.js, i try to set the nuxt.config.js cache: false or cache:{ max: 20, maxAge: 600000 } , but i think it does not work well.
I would like to find a better source of the problem, as well as the solution, thanks!
I have the same problem, but found a workaaround for this. I use idle-gc and --expose-gc flag for node.
@hendrysadrak You have not tried, whether it is caused by the cache mechanism?
@surmon-china I think it is because how node garbage collection is done. It doesnt do gc when you have memory available, when you run out of memory, then it starts gc.
@surmon-china Also, i don't use nuxt start. I did a script which is similiar to https://nuxtjs.org/api/nuxt-render because it uses less memory than nuxt start. But it has some minuses. Like if you want to update site, then you will have some downtime (for me it is 10-15 seconds), even when using pm2.
@hendrysadrak I will try do you solution, thanks!
Hi, thanks for the report.
@surmon-china Can you confirm and close the issue, if it's due to GC and if it solves the problem when you will give a try?
@alexchopin OK:)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.