I work on linux machine and I'd like to set min heap size and also want to increase the max heap size for Java. The RAM is 4GB and the current Max Heap Size is 1GB. Can you please guide me up to what value can I increase the max heap and also what min heap size I need to set for the above configuration.
Asked
Active
Viewed 2.0k times
3
-
use -Xmx for max heap and -Xms for min heap size as command line – ravthiru Aug 17 '16 at 09:29
-
You could make the maximum 3 GB out of 4 GB, but you don't need to set the minimum in many cases. 4 GB is pretty small and I would consider increasing it if you can. – Peter Lawrey Aug 17 '16 at 09:34
-
Thanks Ricardo, Ravthiru, Peter for ur quick response. I want to know is there any effects in the value we set for heap size on 32 bit or 64 bit. Mine is 64 bit OS. – Indrakaran Aug 17 '16 at 10:11
2 Answers
3
Java Heap Size Place to store objects created by your Java application, this is where Garbage Collection takes place, the memory used by your Java application. For a heavy Java process, insufficient Heap size will cause the popular java.lang.OutOfMemoryError: Java heap space.
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
$ java -Xms512m -Xmx1024m JavaApp
Suggested Java Memory Below is suggested value for a small to medium Java application
Heap = -Xms512m -Xmx1024m
Source: https://www.mkyong.com/java/find-out-your-java-heap-memory-size/

Rudziankoŭ
- 10,681
- 20
- 92
- 192
-
Thanks Rudziankou. Actually requirement came to increase the max heap size. So according to u upto what value we can increase the max heap size. – Indrakaran Aug 17 '16 at 10:15
-
I think sane decisions is allow max heap size up to 1/2 you action RAM size. I would suggest increasing of RAM or rethinking GC strategies if you face lack of memory – Rudziankoŭ Aug 17 '16 at 11:10
2
This should help
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
java -Xms4g -Xmx4g ClassName

user2393256
- 1,001
- 1
- 15
- 26