I am using https://www.npmjs.com/package/memory-usage to see how my Node application uses the memory, by running 'memory-usage app.js' in MACOS terminal. However, after some testing, it always crash at 1.4GB.
In normal nodejs command, to set the memory limit higher, I could just use 'node --max-old-space-size=8192 app.js'. However running 'memory-usage --max-old-space-size=8192 app.js' won't work.
My Mac has following RAM details:
BANK 0/DIMM0:
Size: 4 GB Type: DDR3 Speed: 1867 MHz
BANK 1/DIMM0:
Size: 4 GB Type: DDR3 Speed: 1867 MHz
What is the maximum size I can go for my Nodejs application and how to set that with memory-usage?
Thank you.
Try setting it via NODE_OPTIONS
:
Unix:
export NODE_OPTIONS="--max_old_space_size=8192" && memory-usage app.js
Windows:
set NODE_OPTIONS="--max_old_space_size=8192" && memory-usage app.js
Its likely that the memory-usage executable is just ignoring your max-old-space
argument. You should be able to find a way around that in their docs. It looks like Node has default memory allocation of 1G on 64bit systems.
See related (possibly duplicate) thread. Limiting node.js's memory usage
1.4G sounds a bit high to me. I wonder if you're leaking memory somewhere?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.