question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reached Javascript's memory limit

See original GitHub issue

I was trying to convert a project I’m working on here https://github.com/aelgasser/ketcher.

After running ts-migrate init and ts-migrate rename I ran the migrate command, which, you’ll see by the timings below took a lot of time 😃 and eventually crashed over an Out of memory exception.

I’m running the migratin on a Mac Book Pro with macOS Catalina and 32GB of memory (though most of it is used in other tasks). Here a view the actual memory consumption :

image

Here is the call the issue. You can reproduce it with the master branch of my repo above.

ketcher git:(migrate-typescript) ✗ ts-migrate migrate .
forkTSServer
Logs in /var/folders/vx/rv39hv855zl5lnwrd94f2gs80000gr/T/ts-migrate-log-ao3ewO
TypeScript version: 3.9.7
Initialized tsserver project in 166.072ms.
Start...
[strip-ts-ignore] Plugin 1 of 12. Start...
[strip-ts-ignore] Finished in 1212.617ms.
[hoist-class-statics] Plugin 2 of 12. Start...
[hoist-class-statics] Finished in 432.065ms.
[react-props] Plugin 3 of 12. Start...
[react-props] Finished in 39.899ms.
[react-class-state] Plugin 4 of 12. Start...
[react-class-state] Finished in 587.065ms.
[react-class-lifecycle-methods] Plugin 5 of 12. Start...
[react-class-lifecycle-methods] Finished in 87.543ms.
[react-default-props] Plugin 6 of 12. Start...
[react-default-props] Finished in 2.223ms.
[react-shape] Plugin 7 of 12. Start...
[react-shape] Finished in 1.812ms.
[declare-missing-class-properties] Plugin 8 of 12. Start...
[declare-missing-class-properties] Finished in 591643.556ms.
[explicit-any] Plugin 9 of 12. Start...
[explicit-any] Finished in 4281997.169ms.
[eslint-fix] Plugin 10 of 12. Start...

<--- Last few GCs --->

[59989:0x108008000]  5021636 ms: Scavenge 2033.5 (2047.8) -> 2032.2 (2046.5) MB, 10.5 / 0.0 ms  (average mu = 0.335, current mu = 0.350) allocation failure 
[59989:0x108008000]  5021653 ms: Scavenge 2033.5 (2047.8) -> 2033.5 (2047.8) MB, 11.0 / 0.0 ms  (average mu = 0.335, current mu = 0.350) allocation failure 
[59989:0x108008000]  5021675 ms: Scavenge 2034.8 (2049.1) -> 2034.9 (2049.1) MB, 11.0 / 0.0 ms  (average mu = 0.335, current mu = 0.350) allocation failure 


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0x1009ce8d9]
    1: StubFrame [pc: 0x100979382]
Security context: 0x07a6220c08d1 <JSObject>
    2: clone [0x7a605226921] [/Users/abderraouf.elgasser/projects/open_source/ketcher/node_modules/babel-eslint/node_modules/babylon/lib/index.js:~849] [pc=0xb15e09d5d0](this=0x07a615285d99 <State map = 0x7a685504f39>,0x07a672e004b1 <undefined>)
    3: parseConditional [0x7a6cfea7ab1] [/Users/abderraouf.elgasser/projects/open_...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1011bdf85 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x10009d569 node::Abort() [/usr/local/bin/node]
 3: 0x10009d6cf node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001de957 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001de8f7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x100364635 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x100365e8a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x10036290e v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x1003606c0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x10036c4ea v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x10036c571 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x10033a78a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x100689858 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x1009ce8d9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
15: 0x100979382 Builtins_CloneFastJSArray [/usr/local/bin/node]
[1]    59989 abort      ts-migrate migrate .
➜  ketcher git:(migrate-typescript) ✗ 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
owencmcommented, Feb 8, 2022

FWIW for future people experiencing this, my issue was that the same directory I was running this in had some large directories of “built code” (for React Native apps), so I presume it was trying to compile those and running out of memory.

So check the folder you’re running it in doesn’t contain any large directories of code you don’t intend to be compiled, and if it does, use the exclude property in tsconfig.json to exclude them.

1reaction
lencionicommented, Aug 27, 2020

Can you try giving node more memory when running the command? Something like this:

NODE_OPTIONS="--max-old-space-size=10240" ts-migrate migrate .

I’m also curious what version of node are you running?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript memory limit
Maximum size of an Array in Javascript, which suggests you can store up to 232-1 = 4,294,967,295 = 4.29 billion elements. · Maximum...
Read more >
JavaScript Heap Out Of Memory Error
4096 translates to 4 GB of memory. You can set the limit to whatever you like, but make sure you don't use all...
Read more >
Browser Memory Limits - text/plain
For a 32-bit process running on 64bit Windows, a process compiled as LargeAddressAware (like Chromium) can allocate up to 4GB. 32-bit processes ...
Read more >
Node.js Memory Limits - What You Should Know
Expanding Memory Allocation Limits ... This sets the max limit to 8GB. Be careful when doing this. My laptop has ample room with...
Read more >
How to solve JavaScript heap out of memory error
The default Node memory limit varies from version to version, but the latest Node version 15 still has a memory limit below 2GB....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found