How to resolve SOLR Heap size issue?

We recently started facing heap size issue on one of our SOLR instance.

Error: Caused by: java.lang.OutOfMemoryError: Java heap space

I thought it was easy fix by just adding more memory but it wasn’t as forward as I thought. Before you jump to the solution I will share a good link which will explain you the cause of it in the first place.

  1. https://sitecore.stackexchange.com/questions/622/how-much-memory-does-the-jvm-for-solr-need

This can be fixed by updating the memory value double of what is currently present in your SOLR instance (default is 512 MB)

  1. Go to the SOLR instance.
  2. Open solr.in.cmd file (C:\<SOLR instance>\solr-<version>\bin)
  3. Search for “SOLR_JAVA_MEM”.
  4. You will see a commented line – “REM set SOLR_JAVA_MEM=-Xms512m -Xmx512m”.
  5. Remove the REM at the beginning to uncomment it.
  6. Change the value to 1024m – “set SOLR_JAVA_MEM=-Xms1024m -Xmx1024m”
  7. Save the file and restart the service.

Tip: It wasn’t allowing me to use 1024m and the service was throwing error, I used 1000m and it worked.

If the above steps doesn’t work then you can update the values in solr.cmd file.

  1. Search for “SOLR_JAVA_MEM” in Solr.cmd file.
  2. You will see this line – “IF “%SOLR_JAVA_MEM%”==”” set SOLR_JAVA_MEM=-Xms512m -Xmx512m”
  3. Comment the line by adding REM at the beginning.
  4. Add new line line below it – “IF “set SOLR_JAVA_MEM=-Xms1024m -Xmx1024m”
  5. Save the file and restart the service.

The links that I referred while troubleshooting are:

  1. https://sitecore.stackexchange.com/questions/8849/java-lang-outofmemoryerror-during-solr-index-rebuilding
  2. https://horizontal.blog/2016/04/09/solr-core-configuration-considerations/

Thank you.. Keep Learning.. Keep Sitecoring.. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s