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?
请先登录再写评论。
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
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:
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
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 app2. 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
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.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.
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.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/9162760477330-How-do-I-increase-heap-memory-backrooms game