Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase memory size for JVM beyond 1gb

When I try to set -Xms and -Xmx values more than 1gb, I am getting an error:

Error occurred during initialization of VM

My pc has 8GB of RAM.

I need to hold and manipulate a huge amount of data in memory.

like image 864
user2479100 Avatar asked Oct 25 '25 08:10

user2479100


1 Answers

A 32-bit JVM can have a maximum heap size of at most 4GB - in some systems it's less due to various technical reasons (such as the need for contiguous memory). Try using a 64-bit version, assuming you're on a 64-bit machine.

The reason for this is that the maximum number of addresses that you can point to with 32 bits is 2^32, which is 4GB. This theoretical maximum can never really be accessed by the user as it is needed by the JVM for Klass files (the internal representation of your code) and other stuff.

Also see this question.

like image 90
selig Avatar answered Oct 26 '25 22:10

selig