![]() |
|
Performance is affected by size of the memory and Garbage Collection (GC) mechanisms. Memory is managed in generations as memory pools holding objects of different ages. GC occurs in each generation, when the memory fills up.
Objects in Java are created using the new operator. The JVM allocates memory for these objects at runtime. This memory is finite and can exhaust if many objects are created. When this happens, the VM throws an OutOfMemory exception.
To avoid this situation and to make sure that enough memory is allocated to the VM, use the command line flags: Xms and Xmx. It is also a good idea to have the same values for both. This value can be set by deciding how much of heap space would be enough for the run time environment. Setting both the values to the same limit avoids the overhead of adding more memory to the heap at runtime.
To set optimum size for an application, run the application under a typical scenario. A real-life scenario involves:
Ensure that GC occurs regularly at runtime . Set -Xmx at maximum possible value in the server. Determine the actual memory allocated by the VM which is the ideal maximum level. This is important as GC does not happen for some VMs until the threshold is reached.
Note: Minimum level should be 50% of the ideal maximum value.
Decide the memory size based on a continuous monitoring of the system and set it accordingly.
| © Pramati Technologies 2007 | Runs on Pramati Server | Feedback | Legal |