ChatGPT解决这个技术问题 Extra ChatGPT

How to increase IDE memory limit in IntelliJ IDEA on Mac?

I'm using IDEA 12 Leda on Mountain Lion. I wanted to increase the maximum memory that IDE can use. I set the VMOptions in Info.plist file to be -Xmx2048m -ea -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Xbootclasspath/a:../lib/boot.jar

When I open up IDEA, I still see the maximum memory to be 711m.

jps -v shows my VMOptions has been loaded but it's replaced by the following options.

29388  **-Xmx2048m** -ea -XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Xbootclasspath/a:../lib/boot.jar -Xms128m **-Xmx800m** -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=64m -XX:+UseCodeCacheFlushing -XX:+UseCompressedOops -Didea.paths.selector=IdeaIC12 -Dsun.java2d.noddraw=true -Didea.max.intellisense.filesize=2500 -Didea.dynamic.classpath=false -Didea.jars.nocopy=false -Dsun.java2d.d3d=false -Dapple.awt.fullscreencapturealldisplays=false -Dapple.laf.useScreenMenuBar=true -Djava.endorsed.dirs= -Dswing.bufferPerWindow=false -Didea.fatal.error.notification=enabled -Didea.cycle.buffer.size=1024 -Didea.popup.weight=heavy -Didea.xdebug.key=-Xdebug -Dapple.awt.graphics.UseQuartz=true -Dsun.java2d.pmoffscreen=false -Didea.no.launcher=false -DCVS_PASSFILE=~/.cvspass -Didea.use.default.antialiasing.in.editor=false -Dcom.apple.mrj.application.live-resize=false -Didea.smooth.progress=false
29392 Jps -Dapplication.home=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home -Xms8m

Where does -Xmx800 come from? I need to remove it.

just note that for 64-bit the filename needs to be idea64.vmoptions
@Ittai for me idea.vmoptions works for 64 bit as well on mac os 10.9
On OS X 10.10.3 with IntelliJ 14, I had to rename ~/Library/Preferences/IdeaIC14/idea.vmoptions to idea64.vmoptions before it would recognize the change, i.e., -Xmx2048m.
On OS X 10.11 Intellij 15 64-bit, I had to rename idea64.vmoptions to idea.vmoptions to make it work.
See also IDEA options investigation at tomaszdziurko.com/2015/11/…

C
CrazyCoder

Current version: Help | Change Memory Settings:

https://i.stack.imgur.com/3mr53.png

Since IntelliJ IDEA 15.0.4 you can also use: Help | Edit Custom VM Options...:

This will automatically create a copy of the .vmoptions file in the config folder and open a dialog to edit it.

Older versions:

IntelliJ IDEA 12 is a signed application, therefore changing options in Info.plist is no longer recommended, as the signature will not match and you will get issues depending on your system security settings (app will either not run, or firewall will complain on every start, or the app will not be able to use the system keystore to save passwords).

As a result of addressing IDEA-94050 a new way to supply JVM options was introduced in IDEA 12:

Now it can take VM options from ~/Library/Preferences//idea.vmoptions and system properties from ~/Library/Preferences//idea.properties.

For example, to use -Xmx2048m option you should copy the original .vmoptions file from /Applications/IntelliJ IDEA.app/bin/idea.vmoptions to ~/Library/Preferences/IntelliJIdea12/idea.vmoptions, then modify the -Xmx setting.

The final file should look like:

-Xms128m
-Xmx2048m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=64m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops

Copying the original file is important, as options are not added, they are replaced.

This way your custom options will be preserved between updates and application files will remain unmodified making signature checker happy.

Community Edition: ~/Library/Preferences/IdeaIC12/idea.vmoptions file is used instead.


this file worked for me: /Users//Library/Preferences/IdeaIC12/idea.vmoptions
I want to put the properties file outside the application bundle, because editing the .app bundle will cause its code signature to break and/or need redoing after every update.
On Mac OS X 10.8.3 and IntelliJ IDEA Ultimate 12.1.4 the correct command was $ cp -i /Applications/IntelliJ\ IDEA\ 12.app/bin/idea.vmoptions ~/Library/Preferences/IntelliJIdea12/. This matches the latest IDEA configuration docs at jetbrains.com/idea/webhelp/increasing-memory-heap.html as mentioned by michael-m.
cp /Applications/IntelliJ\ IDEA\ 13.app/bin/idea.vmoptions ~/Library/Preferences/IntelliJIdea13/idea.properties and then vi ~/Library/Preferences/IntelliJIdea13/idea.properties
If you are on OSX and using PHPStorm, you can copy it to ~/Library/Preferences/WebIde80/idea.properties (use WebIde70 if you are using phpstorm 7)
T
TrophyGeek

[Updated Aug 2021 since the JetBrains UI has changed]

Helpful trick I thought I'd share on this old thread.

You can see how much memory is being used and adjust things accordingly using the Memory Indicator

Right click in the bottom most taskbar area and select the Memory Indicator item

https://i.stack.imgur.com/Rx4Sa.png

It shows up in the lower right of the window.

https://i.stack.imgur.com/3kuTy.png


Make sure you have the ViewStatus Bar enabled too.
Wow, you use -Xmx=8G?
Is there any way to have this show the memory usage of the application you're running from IntelliJ, rather than the IDE's memory usage?
This is now in View > Appearance > Status bar widgets > Memory indicator
u
ujay68

For IDEA 13 and OS X 10.9 Mavericks, the correct paths are:

Original: /Applications/IntelliJ IDEA 13.app/Contents/bin/idea.vmoptions

Copy to: ~/Library/Preferences/IntelliJIdea13/idea.vmoptions


I don't have IntelliJIdea13 folder inside ~/Library/Preferences. Tried to create it and put the file inside but no luck. Any other tips?
S
StartupGuy

Here is a link to the latest documentation as of today http://www.jetbrains.com/idea/webhelp/increasing-memory-heap.html


That is only about increasing the heap for the compiler, not for the IDE.
@Zayenz :: False. It's not "only" about increasing the heap for the build process, but it also includes information to answer the question - i.e. Under the "Notes" it says.... The memory heap available to IntelliJ IDEA may be changed by editing the corresponding VM options. Depending on the platform, these files are:..... - TLDR for you?
@michael-m Sorry. I did read, but somehow missed that note. Thanks for correcting me.
r
rinkesh

go to that path "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.4\bin\idea.exe.vmoptions" and change size to -Xmx512m

  -Xms128m
  -Xmx512m
  -XX:MaxPermSize=250m
  -XX:ReservedCodeCacheSize=64m
  -XX:+UseCodeCacheFlushing
  -ea
  -Dsun.io.useCanonCaches=false
  -Djava.net.preferIPv4Stack=true

hope its will work


That's true for windows, but not OSX, which is what the question is about.
found it, and it has helped me in windows! Thanks!
A
Avishek Bhattacharya

As for the intellij2018 version I am using the following configuration for better performance

-server
-Xms1024m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=512m
-XX:+UseCompressedOops
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:-TraceClassUnloading
-XX:+TieredCompilation
-XX:SoftRefLRUPolicyMSPerMB=100
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Xverify:none

-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof

Thanks Avishek..Will surely give it a try to this config on intellij IDEA 2018
B
BeetleJuice

More recent versions of IntelliJ (certainly WebStorm and PhpStorm) have made this change even easier by adding a Help >> Change Memory Settings menu item that opens a dialog where the memory limit can be set.

https://i.stack.imgur.com/GwLOS.png


A
Arneball

OSX 10.9, if you dont bother about signed application you might just change

/Applications/IntelliJ\ IDEA\ 12\ CE.app/bin/idea.vmoptions

a
ajtrichards

On my machine this only works in bin/idea.vmoptions, adding the setting in ~/Library/Preferences/IntelliJIdea12/idea.vmoptions causes the IDEA to hang during startup.


Please see my updated answer. Note that idea.vmoptions in the Preferences doesn't add options, it replaces them. Therefore you need to copy the original file from the bin directory and then modify it.
M
Michael Bushe

It looks like IDEA solves this for you (like everything else). When loading a large project and letting it thrash, it will open a dialog to up the memory settings. Entering 2048 for Xmx and clicking "Shutdown", then restarting IDEA makes IDEA start up with more memory. This seems to work well for Mac OS, though it never seems to persist for me on Windows (not sure about IDEA 12).


a
abmap

Some addition to the top answer here https://stackoverflow.com/posts/13581526/revisions

Change memory as you wish in .vmoptions Enable memory view as told here https://stackoverflow.com/a/39563251/5515861

And you'll have something like this in the bottom right

https://i.stack.imgur.com/BgGjA.png


D
Denys

I use Mac and Idea 14.1.7. Found idea.vmoptions file here: /Applications/IntelliJ IDEA 14.app/Contents/bin

details


R
Richard Tyler Miles

I edited the config file from the editor and on the next reboot IntelliJ would not open even after updating to the newest version. After opening IntelliJ manually using /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea in terminal the output gave me additional insight on where the .vmoptions copy is stored.

➜  ~ /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea
2022-04-21 13:01:55.189 idea[1288:14841] allVms required 1.8*,1.8+
2022-04-21 13:01:55.192 idea[1288:14845] Current Directory: /Users/richardmiles
2022-04-21 13:01:55.192 idea[1288:14845] parseVMOptions: IDEA_VM_OPTIONS = (null)
2022-04-21 13:01:55.192 idea[1288:14845] fullFileName is: /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions
2022-04-21 13:01:55.192 idea[1288:14845] fullFileName exists: /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions
2022-04-21 13:01:55.192 idea[1288:14845] parseVMOptions: /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions
2022-04-21 13:01:55.192 idea[1288:14845] parseVMOptions: /Applications/IntelliJ IDEA.app.vmoptions
2022-04-21 13:01:55.195 idea[1288:14845] parseVMOptions: /Users/richardmiles/Library/Application Support/JetBrains/IntelliJIdea2022.1/idea.vmoptions
2022-04-21 13:01:55.195 idea[1288:14845] parseVMOptions: platform=17 user=1 file=/Users/richardmiles/Library/Application Support/JetBrains/IntelliJIdea2022.1/idea.vmoptions
Invalid maximum heap size: -Xmx2048m -Drun.processes.with.pty=true
Invalid maximum heap size: -Xmx2048m -Drun.processes.with.pty=true
2022-04-21 13:01:55.266 idea[1288:14845] JNI_CreateJavaVM (/Applications/IntelliJ IDEA.app/Contents/jbr) failed: -6

Note when you work with the path remember to quote properly like so!

vim "/Users/richardmiles/Library/Application Support/JetBrains/IntelliJIdea2022.1/idea.vmoptions"

My personal issue was not providing one argument per line!