3

I got this error since week in my live server when I load some of pages of my web panels it will give me 504 gateway time out and server will give this error:

enter image description here

when I put my server in nodemon and run line this :

nodemon --max_old_space_size=4098 server.js

it will work fine but I have to run my server in forever. I dont getting why my node process is giving this error

Vishal G. Gohel
  • 1,008
  • 1
  • 16
  • 31

2 Answers2

2

Memory can now be increased with an environment variable. Set you environment variable like this

export NODE_OPTIONS=--max_old_space_size=4096

this this answer

Max
  • 5,733
  • 4
  • 30
  • 44
0

I think by default node gives you 1.7GB of heap you can use. You're going above this level which is causing the error. As far as I know you need to use the command arguments of max_old_space_size to give it a custom heap ram limit. I don't think there's a global way to set this besides just making it part of your deploy script.

I'd suggest looking at how your app is storing memory and see if you can get rid of memory in arrays and such that you don't need. If it's DB related then you may need to only do queries on a smaller chunk of data at a time.

Prodigle
  • 1,757
  • 12
  • 23