How can I increase the global heap size for java on Mac OSX
Asked Answered
G

2

7

Apple has seen fit to remove the Java Preferences app from the Utilities folder so there's no longer any GUI way to go about increasing the allocated memory limit for Java.

I'm not really a commandline guy so I thought I'd ask here.

I have a few apps that need large memory allocations, I'm running 16GB of RAM on this machine so I'm not concerned about running other apps while these run, not to mention I don't run these apps very often.  I'd like to increase my allowed memory limit to 6144m but I can't see how to do it correctly.

This is the code I found but after running it and checking my Activity Monitor the app in question is still only accessing about 800m and it eventually uses up the heap and crashes.

export _JAVA_OPTIONS='-Xmx6144m'

Can someone please help me with this?

Guessrope answered 21/10, 2012 at 3:58 Comment(5)
how do you start the apps? you can usually pass in jvm arguments there.Picot
The apps are started by double clicking on the icon as normal.Guessrope
If you right or ctrl-click the application and select "View Package Contents" you may have a configuration file where you can set the jvm options, typically an ini. For Eclipse it is Content>MacOS>eclipse.ini, so it may be something similar for your apps.Picot
Cool that was a good tip, there's a .plist file in there with the allocation settings ... but ... if I change them it won't start up at all. I think maybe is has to do with it being a 32bit app and the 1gb memory limit?Guessrope
there should bea 2gb limit on 32bit apps, but there is also overhead. try 1.7G and see if that works.Picot
P
3

From this article on the missing Java Preferences after the recent update it looks like you can download Java 1.7 and will then have access to Oracle's Java Preferences under System Preferences.

Note that your apps may or may not run under Java 1.7 - upgrading can always be risky.

Picot answered 21/10, 2012 at 5:16 Comment(1)
Ok well since I can't access the 1.7 64bit JVM with a 32bit app, or at least not with these anyway, I was able to change the Xmx to 2048 which was the highest it would take and still start up. Hopefully that will give it enough juice to do what I need.Guessrope
A
1

The trick is to edit /etc/launchd.conf (you need to do this as an administrator); adding

setenv _JAVA_OPTIONS "-Xmx6144m"
  • note that this won't work on MacOS 10.10 and above, requiring you to do this instead.
Amice answered 21/10, 2012 at 4:22 Comment(3)
Those are Windows options, not Mac.Picot
Yeah no love on that, it still only gets to 945m and won't go beyond in the Activity Monitor. @Picot do you know what the Mac equivalent would be? This is what is recommended for Mac on the product creator's website.Guessrope
sadly launchd.conf is no longer an option since MacOS 10.10 (it got removed due to security reasons)Nepotism

© 2022 - 2024 — McMap. All rights reserved.