Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

I'm using Eclipse to run java program class, while I run it i got this error

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

then i changed the VM from the Properties > Run > VM Options, and I run the program again i got a new error,

Error occurred during initialization of VM
Incompatible initial and maximum heap sizes specified

I'm trying to apply stanford libraries in my program, any idea how to solve this error .

like image 523
S Gaber Avatar asked Feb 27 '12 04:02

S Gaber


People also ask

How do I fix this exception in thread main Java Lang OutOfMemoryError Java heap space?

As explained in the above paragraph this OutOfMemory error in java comes when the Permanent generation of heap is filled up. To fix this OutOfMemoryError in Java, you need to increase the heap size of the Perm space by using the JVM option "-XX: MaxPermSize".

What causes Java heap space error?

Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further.

How do I fix a heap space error?

The java. lang. OutOfMemoryError: Java heap space error occurs when it attempts to add more data into the heap space area, but there is not enough room for it. The solution to fix this problem is to increase the heap space(Default value maybe 128 MB).

How do I fix internal exception in Java Lang OutOfMemoryError?

If you encounter this error before the server “Start Up Done” message displays and is confirmed online, then your server will most likely need more RAM in order to start. You can either upgrade your server plan or your will need to downsize your servers intended function.


1 Answers

to change the VM for Eclipse you can change the amount of the MV from Windows> Preferences> Java> Installed JREs from there select the JRE and click edit, then write in the Default VM Arguments: to -Xmx1024M or any other amount of memory ...

like image 55
S Gaber Avatar answered Oct 31 '22 00:10

S Gaber