Java Heap Space OutOfMemoryError When Using Solr And Apache
If you get the Java Heap Space OutOfMemoryError in Apache Tomcat, then there's quite an easy fix *.
In Apache Tomcat, you can customize the memory settings, thus allowing more memory to Java clients like Solr.
Just fire up "Configure Tomcat", click on the "Java" tab and allocate enough memory in the "Initial memory pool" and "Maximum memory pool" fields:
What memory size should you allocate here? Well, it depends. The default initial memory pool is 64 MB. If you've got a pretty large search index with many searches, you'll surelly need more memory allocated.
In a project here, where we've got approximately 20 Million indexed items being searched, 256 MB weren't enough as initial memory pool. 512 MB so far seems to work it out. I guess you just have to try some different values out, and monitor Tomcat's performance while fine-tuning.
* Also take a look at my other blog post on Java heap space issues and 32 / 64 bit versions of Apache Tomcat and Java.