I have an Angular application that has recently been converted to Angular Universal. The application is based on Angular 15 and is running inside a Docker container. The command used to initiate the server is "npm serve:ssr". The application runs fine for a day or two, but after that, it throws the error "ineffective mark-compacts near heap limit allocation failed - javascript heap out of memory".
To address this issue, I tried increasing the memory by adding the flag "max-old-space-size" to 3072. I modified the "serve:ssr" script in the package.json file to "node --max-old-space-size=3072 {project-name}/server/main.js". However, the problem still persists, causing my server to go down.
Here's the code snippet for the modified "serve:ssr" script in the package.json file
"scripts": {
"serve:ssr": "node --max-old-space-size=3072 {project-name}/server/main.js"
},
Could you please help me understand why I'm still encountering this "out of memory" error despite increasing the memory allocation? Are there any additional steps or configurations I should consider to prevent this issue from occurring? Thank you in advance for your assistance.