Tag Archives: javascript heap out of memory

[Solved] Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory

Problem description

After the project is run and compiled, the problem of running interruption occurs frequently. You need to re execute the command yarn serve


Error content

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

The JS heap is out of memory

Cause analysis:

If the project is large, memory overflow will be thrown when starting or packaging, and the node server memory needs to be expanded


Solution:

Try method 1: Expand memory
Shortcut key Win+R to open the run window, run npm install -g increase-memory-limit 2. Run increase-memory-limit
in the project folder , the memory expansion is completed, and then start the project.

The situation is slightly better after the expansion, but the operation will be interrupted when throwing

CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory

Try method 2: Shortcut key Win+R to open the run window, run setx NODE_OPTIONS –max_old_space_size=4096

Subsequent operation is normal, no error is reported

[Solved] Project Package Error: Javascript heap out of memory

Project package error:JavaScript heap out of memory
1、Modify package.json add –max_old_space_size=8192

"pro": "cross-env NODE_ENV=production node --max_old_space_size=8192 ./dist/server/server.js",

2. Execute increase memory limit


// global install
npm i -g increase-memory-limit

// into the project
increase-memory-limit

Error JavaScript heap out of memory means that the JavaScript heap is out of memory. JavaScript here refers to node. We all know that node is based on V8 engine. In general back-end development languages, there are no restrictions on the use of basic memory. However, when using memory through JavaScript in node, only part of the memory can be used (about 1.4 GB in 64 bit system and about 0.7 GB in 32-bit system). If the front-end project is too large, webpack compilation will occupy a lot of system resources. When it exceeds the default memory limit of V8 for node, memory leakage will occur.