Vue 项目内存溢出
ps:每次修改代码后,编译器重新编译报错,内存溢出,程序运行停止
报错
<--- Last few GCs --->
[8476:0000018AB274A6A0] 236375 ms: Scavenge 3607.6 (4086.1) -> 3596.0 (4086.1) MB, 5.09 / 0.00 ms (average mu = 0.323, current mu = 0.275) task;
[8476:0000018AB274A6A0] 237903 ms: Mark-Compact (reduce) 4412.0 (4890.5) -> 4242.7 (4819.2) MB, 427.78 / 0.11 ms (+ 117.7 ms in 39 steps since start of marking, biggest step 28.7 ms, walltime since start of marking 570 ms) (average mu = 0.803, current
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 00007FF60FAF0B6B node::SetCppgcReference+18123
2: 00007FF60FA624D8 DSA_meth_get_flags+92504
3: 00007FF6104D9821 v8::Isolate::ReportExternalAllocationLimitReached+65
4: 00007FF6104C2F78 v8::Function::Experimental_IsNopFunction+1336
5: 00007FF610324A20 v8::Platform::SystemClockTimeMillis+659328
6: 00007FF610321AA8 v8::Platform::SystemClockTimeMillis+647176
7: 00007FF6103293CA v8::Platform::SystemClockTimeMillis+678186
8: 00007FF61037AE0E v8::Locker::IsLocked+6366
9: 00007FF610007D86 v8::CodeEvent::GetFunctionName+122774
10: 0000018AD421AAFA
解决方案:
删除 node_modules 和 package-lock.json
执行命令
npm install increase-memory-limit
执行命令
npm install cross-env
在package.json文件中加入如下代码:(如果 3072 不够,就加 8192)
"scripts": { "fix-memory-limit": "cross-env LIMIT=3072 increase-memory-limit" },
执行命令
npm run fix-memory-limit
重启项目
如果报错:
'"node --max-old-space-size=3072"' 不是内部或外部命令,也不是可运行的程序或批处理文件。
在 node_modules 下的 .bin 目录,替换所有
“%_prog%”
为%_prog%
(即删除双引号)重启项目即可