TypeScript service crashed due to 'Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory' error in IntelliJ

Viewed 5388

Here is the configuration of the typescript service in IntelliJ IDEA:

enter image description here

The service crashed and respawned continuously, and here is the log output

Process: TypeScript service version: 3.2.1
Process: Default service options: {"baseUrl":"/Users/antkong/dev/myproject/src","experimentalDecorators":true,"importHelpers":false,"jsx":2,"lib":["lib.dom.d.ts","lib.dom.iterable.d.ts","lib.es2018.d.ts"],"moduleResolution":2,"outDir":"/Users/antkong/dev/myproject/target","strict":true,"skipLibCheck":true,"target":2,"sourceMap":true,"module":6,"configFilePath":"/Users/antkong/dev/myproject/tsconfig.json"}
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1000389cc node::Abort() [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 2: 0x100038ba8 node::FatalTryCatch::~FatalTryCatch() [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 3: 0x1001a9d5a v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 4: 0x100578772 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 5: 0x100577729 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 6: 0x1005753b8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 7: 0x1005818fc v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 8: 0x100550294 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
 9: 0x1007daf84 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
10: 0x4986b2841bd 

Disconnected

Is there any way I can increase the heap size of the node process?

1 Answers

There is a hidden option that allows passing arguments to Node.js process that runs TypeScript service - typescript.service.node.arguments.

  • in Help | Find action..., type registry
  • open Registry, locate typescript.service.node.arguments key there (you can start typing property name to navigate to it)
  • add --max_old_space_size option there (--max_old_space_size=4096, for example)

See https://github.com/thlorenz/v8-flags/blob/master/flags-0.11.md#max_old_space_size-0-integer

See also https://www.npmjs.com/package/increase-memory-limit - you may find this utility helpful

Related