堆限制分配失败-JavaScript堆内存不足-ng服务后Angular 4编译错误

时间:2018-11-19 09:29:10

标签: node.js angular

当我给出ng serve命令时,会发生此错误。我的NODE版本是v11.0.0,NPM版本是6.4.1。我正在使用Ubuntu。

我尝试了各种解决方案,例如更新节点和npm,还更新了ng.cmd文件,如下所示:

  

@IF EXIST“%〜dp0 \ node.exe”(“%〜dp0 \ node.exe”   –max_old_space_size = 8192“%〜dp0 .. \ @ angular \ cli \ bin \ ng”%*)ELSE(
  @SETLOCAL @SET PATHEXT =%PATHEXT:;。JS; =;%节点   –max_old_space_size = 8192“%〜dp0 .. \ @ angular \ cli \ bin \ ng”%*)

但是此解决方案不适用于我。

我不断收到下面显示的错误

[25343:0x2993860]   103014 ms: Scavenge 1209.7 (1434.1) -> 1203.9 (1434.1) MB, 6.7 / 0.0 ms  (average mu = 0.245, current mu = 0.226) allocation failure 
[25343:0x2993860]   103064 ms: Scavenge 1215.7 (1434.1) -> 1210.6 (1434.6) MB, 6.7 / 0.0 ms  (average mu = 0.245, current mu = 0.226) allocation failure 
[25343:0x2993860]   103119 ms: Scavenge 1222.1 (1434.6) -> 1215.2 (1434.6) MB, 7.8 / 0.0 ms  (average mu = 0.245, current mu = 0.226) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x2068d904fb5d]
Security context: 0x38a97bf9d969 <JSObject>
    1: byteLength(aka byteLength) [0xdf8960fb3f9] [buffer.js:524] [bytecode=0x1e5e5154501 offset=204](this=0x11b173e025b1 <undefined>,0x1acdd568e6e9 <Very long string[35847]>,0x38a97bfbc249 <String[4]: utf8>)
    2: arguments adaptor frame: 3->2
    3: fromString(aka fromString) [0x2d0b18994f51] [buffer.js:335] [bytecode=0x1e5e514ef89 offset=74](this=0x11b17...
    enter code here

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x90af00 node::Abort() [ng]
 2: 0x90af4c  [ng]
 3: 0xb05f9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng]
 4: 0xb061d4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng]
 5: 0xf0c6f2  [ng]
 6: 0xf0c7f8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [ng]
 7: 0xf18f88 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng]
 8: 0xf19b1b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng]
 9: 0xf1c851 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [ng]
10: 0xee58b5  [ng]
11: 0xeed1ab v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [ng]
12: 0x103c098 v8::internal::String::SlowFlatten(v8::internal::Isolate*, v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [ng]
13: 0xb03f0b v8::internal::String::Flatten(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [ng]
14: 0xb104d9 v8::String::Utf8Length(v8::Isolate*) const [ng]
15: 0x923e99  [ng]
16: 0xb8d2ca  [ng]
17: 0xb8de65 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [ng]
18: 0x2068d904fb5d 
Aborted (core dumped)

请为此提出解决方案。

1 个答案:

答案 0 :(得分:0)

检查可用内存,然后尝试重新启动Nginx服务器。有时服务器缓存会占用大量空间