Thank you for visiting!

Please consider subscribing to the RSS feed or following me on Twitter.

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:

Apache Tomcat 7 Java Memory settings

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.


Fegt med grafiskt fönster för inställningar ;-)

Bra litet tips annars.
Har tidigare haft lite problem med det där på JBoss (fast -Xms och -Xmx parametrar) när jag ska sätta upp utvecklingsmiljö för hela system i en liten VMWare på min laptop. Fin balansgång mellan tillåten användning av minne och "out of memory" =)

(orka inte skriva på engelska)

great article just to add Many people confused between <a href="">Java heap</a> and stack though both represent memory they are completely different to each other. Stack is where local variable are created or method stack trace are stored while heap is the memory where Java creates or keeps objects.

Very good article, really a great explanation ,

I would like to share the link <a href="">about simple and primary explanation of java heap space</a>

Please ignore the link in above comment
Here is the link

To the top