Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change max memory heap for Java on Mac OS X

Tags:

java

macos

scala

I am trying to change the max memory size "heap" for Java on Mac OS X. I have read many places to change "-XX:MaxPermSize", but I can't find the file and don't know where to change that setting.

like image 947
user1435853 Avatar asked Jun 04 '12 19:06

user1435853


People also ask

How do I check my Java heap size?

Open a terminal window. Review the command output. The argument beginning with "-Xmx" will give you the value of the current Java heap space. In the example above, the value is 1024 MB, or 1 GB.

What is the maximum Java heap space?

The theoretical limit is 2^64 bytes, which is 16 exabytes (1 exabyte = 1024 petabytes, 1 petabyte = 1024 terabytes). However, most OS's can't handle that. For instance, Linux can only support 64 terabytes of data. Note: We don't recommend you exceed 2 GB of in use JVM heap.


2 Answers

you can set the memory available to the java VM using this parameters:

-Xms64m -Xmx200m

-Xms specifies the minimum memory; -Xmx the maximum one.

You have to specify them when you run your app. For example, if you a jar named app.jar, you can run it typing

java -Xms64m -Xmx512m -jar app.jar

I think that on a 32 bit machine you can't give the JVM more than 1Gb.

like image 120
smellyarmpits Avatar answered Sep 30 '22 19:09

smellyarmpits


I was using the WEKA and I got the same problem. Here, I found the solution, and it was easy.

Go to Application==> Left click on specific application (like Weka)==> Show Package Content==> Contents==>Info.Plist==>Java==> VMOptions==> increase the size of memory as you want (in my mac the default was 1 Gb, I increased to 6 Gb)

like image 22
Prem Avatar answered Sep 30 '22 18:09

Prem