JVM configuration
One of the things that you need to take particular care of when you are working on any Java-based application is configuring the JVM optimally, and Solr is no exception.
Managing the memory heap
Anyone who has worked with Java-based applications would have surely come across setting the heap space. We do it using -Xms
and -Xmx
. Suppose I set following the command-line option:
-Xms256m-Xmx2048m
Here, Xms
specifies our initial memory allocation pool, whereas Xmx
specifies the maximum memory allocation pool for JVM. In the case we just saw, our JVM will start with 256 MB of memory and will be able to use up to 2 GB of memory.
If we require more heap space, then we can increase -Xms
. We can also decide not to give any initial heap space at all and let JVM use the heap space as per the need, but this may increase our startup time. Similarly, failing to set up the maximum heap size properly can result in OutOfMemoryException
. Proper garbage collection JVM parameters should be set...