How do I increase heap memory?

I have a NodeJS ReactJS application that has over 60 MB and when I try to start in in WebStorm I receive the error: 

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

How can I increase memory in WebStorm?

0
7 comments

Your application runs out of memory. You can try giving it more memory by passing the --max_old_space_size option to Node.js (--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-intege

1

I tried 3 things:

1) I increased the --max_old_space_size using instructions from here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003472280-JS-Heap-Out-of-Memory-WS-2019-1-1

2) In "Help/Custom VM options"  I have this setting: -Xmx20000m

3) In "Help/Change memory settings" I have the value 20000

But the problem is the same, app starts and when I click everywhere in my menu I receive the error:

<--- Last few GCs --->

[7420:000001B755E45FD0]   106504 ms: Mark-sweep 3675.6 (4143.8) -> 3659.3 (4129.3) MB, 1091.8 / 0.0 ms  (average
 mu = 0.113, current mu = 0.053) allocation failure; GC in old space requested
[7420:000001B755E45FD0]   107742 ms: Mark-sweep 3677.2 (4143.9) -> 3655.3 (4130.2) MB, 1152.6 / 0.0 ms  (average
 mu = 0.091, current mu = 0.069) allocation failure; GC in old space requested


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory        
 1: 00007FF6C01D1ADF node_api_throw_syntax_error+203775
 2: 00007FF6C01514B6 SSL_get_quiet_shutdown+63558
 3: 00007FF6C0152822 SSL_get_quiet_shutdown+68530
 4: 00007FF6C0BF2F34 v8::Isolate::ReportExternalAllocationLimitReached+116
 5: 00007FF6C0BDE2A2 v8::Isolate::Exit+674
 6: 00007FF6C0A602FC v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124
 7: 00007FF6C0A6D5DD v8::internal::Heap::PublishPendingAllocations+1117
 8: 00007FF6C0A6A667 v8::internal::Heap::PageFlagsAreConsistent+3367
 9: 00007FF6C0A5CD97 v8::internal::Heap::CollectGarbage+2039
11: 00007FF6C0A73FFD v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93
12: 00007FF6C0A7C94A v8::internal::Factory::AllocateRaw+810
13: 00007FF6C0A8FD8D v8::internal::FactoryBase<v8::internal::Factory>::NewHeapNumber<0>+685
14: 00007FF6C0A94238 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString+72
15: 00007FF6C083BF94 v8::internal::String::SlowFlatten+724
16: 00007FF6C0BFCB4D v8::String::Utf8Length+141
17: 00007FF6C0176971 v8::internal::Malloced::operator delete+17217
18: 00007FF6C0BABAAD v8::internal::Builtins::code+247949
19: 00007FF6C0BAB6B9 v8::internal::Builtins::code+246937


The changes don't seem to affect the memory settings, as the error shows: "(4143.8) -> 3659.3 (4129.3) MB" seems to be a limitation at about 4 GB

 

0

1.  https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003472280/comments/360000457780 describe the way to give more memory to Typescript language service through a Registry key. But in your case it's your application that runs out of memory, not a language service or the IDE. So you need passing --max_old_space_size option to Node.js in the run configuration you use to start your app

2. Help/Edit Custom VM options is used to increase java heap size for the IDE. It won't help here, as it's not the IDE that runs out of heap space

3. same as above - it's about changing IDE memory settings and you need changing your application settings

1

In Windows I've set a variable like this: NODE_OPTIONS=--max_old_space_size=20000 as found in one of the links provided and this solved the problem. Thank you.

0

SEO SPAM in the comment above

1

elena

1.  https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003472280/comments/360000457780 Car Games describe the way to give more memory to Typescript language service through a Registry key. But in your case it's your application that runs out of memory, not a language service or the IDE. So you need passing --max_old_space_size option to Node.js in the run configuration you use to start your app

2. Help/Edit Custom VM options is used to increase java heap size for the IDE. It won't help here, as it's not the IDE that runs out of heap space

  1. The process of increasing heap memory depends on the platform and the application you are using. Here are some general steps that you can follow:

    PyCharm: From the main menu, select Help | Change Memory Settings. Set the necessary amount of memory that you want to allocate and click Save and Restart.
    Java: You can increase heap size allocated by the JVM by using these command line options:
    -Xms<size> set initial Java heap size
    -Xmx<size> set maximum Java heap size
    -Xss<size> set java thread stack size In the following example, minimum heap size is set to 16mb, and the maximum to 64mb.
    IntelliJ IDEA: Click Configure to increase the amount of memory allocated by the JVM. If you are not sure what would be a good value, use the one suggested by IntelliJ IDEA. Click Save and Restart and wait for IntelliJ IDEA to restart with the new memory heap setting.
    Application Server: To increase the Application Server JVM heap size, log in to the Application Server Administration Server. Navigate to the JVM options. Edit the -Xmx256m option. This option sets the JVM heap size. Set the -Xmx256m option to a higher value, such as Xmx1024m. Save the new setting.

0

Click Configure to make the JVM give more memory to the program. If you don't know what a good number would be, use the one that IntelliJ IDEA suggests.

0

Please sign in to leave a comment.