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 .
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".
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.
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).
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.
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 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With