Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 209
Vince Kronlein Avatar asked Oct 21 '12 03:10

Vince Kronlein


People also ask

What is maximum heap size for 64 bit or x64 JVM is it 8gb or 16gb?

For 64 bit platforms and Java stacks in general, the recommended Maximum Heap range for WebSphere Application Server, would be between (4096M - 8192M) or (4G - 8G).

How do I increase allocated heap size?

On Mac OSX one can easily change heap size by going to first menu item, Android Studio > preference > System Settings (left menu) > Memory Settings and change heap size there in the dialog. Save this answer.


2 Answers

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.

like image 72
doublesharp Avatar answered Nov 13 '22 17:11

doublesharp


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.
like image 1
Tom Avatar answered Nov 13 '22 18:11

Tom