Skip to content
Advertisement

Increasing memory through terminal in linux through “-XX:PermSize=192m -XX:MaxPermSize=2g -Xms2g -Xmx2g”

I am running java developer IDE and in a process of trouble shooting a module . For this i have increased the logging memory of the tool, Now when logging it error is coming on console as

Uncaught exception
java.lang.OutOfMemoryError: Java heap space 

i am using below command for increasing memory

"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=2g -Xms2g -Xmx2g"

earlier it is

"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=1024m -Xms1024m -Xmx1024m"

my system memory is 16 GB through the command cat /proc/meminfo but the system free memory is less than 1 GB when exception

Uncaught exception
    java.lang.OutOfMemoryError: Java heap space

is coming , I have allocated maximum memory to be utilized as 2gb

 -XX:MaxPermSize=2g

but it is occupying approximately all available memory.

Do not know whether this command is help full or not whether could i assign more memory like below command

"-XX:CompileThreshold=8000 -XX:PermSize=192m -XX:MaxPermSize=10g -Xms10g -Xmx10g"

increasing it to 10g will be good or not , or is there any problem with my command.

Advertisement

Answer

Use -Xms1024m -Xmx1024m to control your heap size (1024m is only for demonstration, the exact number depends your system memory). Setting minimum and maximum heap size to the same is usually a best practice since JVM doesn’t have to increase heap size at runtime

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement