Node.js Default Memory Settings
💥 Allocation failed — process out of memory
If you have seen the error above, it means your NodeJS application has ran out of memory, it has consumes more memory than what is allocated and that eventually caused it to kill itself.
One of the scenarios when this happens is when the application batch processes a very large set of data, and the data processing algorithm is written in a way such that it needs to hold onto the objects in heap space until the processing is done.
The application gradually uses more memory as the processing is ongoing, V8 will spend more time on garbage collection in an effort to free unused memory, until it eventually reaches the limit allocated to the process and results in OOM.
Node.js runtime is efficient on memory usage, so programs usually run well using the default limit. However, you should be aware that if the maximum heap size is not set, a default memory limit will be imposed, and this default value varies based on the Node.js version and architecture of the system the program is running in.
Default Memory Limits
There is no official disclosed numbers regarding the default limits, but with a small program designed to push the process until it goes out of memory to capture the…