Increasing size of heap memory in Java

Default featured post

In Java size of heap memory by default is 64MB, however if your application holds many objects then you might get the following exception,

java.lang.OutOfMemoryError: Java heap space

There is a simple solution for the problem and it would be reached by increasing your heap size on runtime with the following command,

$ java -Xms256m -Xmx1024m YourClassName/JarFileName

The first parameter defines the minimum heap size and the second parameter sets the maximum size of heap for your application.