[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

Read More: