As with every application written in Java, sometimes memory problems happen. When talking about Solr, those problems are usually related to heap size. They usually happen when the heap size is too low. This recipe will show you how to deal with those problems and what to do to avoid them.
Let's consider what to do when we see an exception like this:
SEVERE: java.lang.OutOfMemoryError: Java heap space
Firstly, you can do something to make your task easier. You can add more memory that the Java virtual machine can use if you have some free physical memory available in your system. To do that, you need to add the Xmx
and, preferably, the Xms
parameter to the start-up script of your servlet container (Apache Tomcat or Jetty). To do that, I used the default Solr deployment and modified the parameters. This is how Solr was run with more than the default heap size:
java –Xmx1024M –Xms512m –jar start.jar