I'm using 64bit Ubuntu and java vm 64 bit version.
I have 8GB ram.
I am unable to change the java heap size to 4096m, not even 2048m.
I tried these things:
uname -i
Output:
x86_64
java -version
OUTPUT:
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)
When I tried to change the heap size:
java -Xmx:4096m
OUTPUT
Invalid maximum heap size: -Xmx:4096m
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
The same for 2048m size
java -XX:+PrintFlagsFinal -version | grep HeapSize
OUTPUT:
size_t ErgoHeapSizeLimit = 0 {product} {default}
size_t HeapSizePerGCThread = 43620760 {product} {default}
size_t InitialHeapSize = 130023424 {product} {ergonomic}
size_t LargePageHeapSizeThreshold = 134217728 {product} {default}
size_t MaxHeapSize = 2067791872 {product} {ergonomic}
uintx NonNMethodCodeHeapSize = 5835340 {pd <p>product} {ergonomic}
uintx NonProfiledCodeHeapSize = 122911450 {pd <p>product} {ergonomic}
uintx ProfiledCodeHeapSize = 122911450 {pd <p>product} {ergonomic}
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)
First check the default value:
java -XshowSettings:vm
then you'll need to edit the settings file for the JVM: sudo vim /etc/profile
Add this to the beginning of the file:
export _JAVA_OPTIONS=-Xmx(size you want in here)m
Press ESC, type :wq
and press Enter
After that you can execute the same command to check if the size was changed:
java -XshowSettings:vm
The correct format is:
java -Xmx4G -jar test.jar
You can test it with:
java -Xmx4G -XX:+PrintFlagsFinal -version | grep HeapSize
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.