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.
This can be fixed by updating the memory value double of what is currently present in your SOLR instance (default is 512 MB)
- Go to the SOLR instance.
- Open solr.in.cmd file (C:\<SOLR instance>\solr-<version>\bin)
- Search for “SOLR_JAVA_MEM”.
- You will see a commented line – “REM set SOLR_JAVA_MEM=-Xms512m -Xmx512m”.
- Remove the REM at the beginning to uncomment it.
- Change the value to 1024m – “set SOLR_JAVA_MEM=-Xms1024m -Xmx1024m”
- 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.
- Search for “SOLR_JAVA_MEM” in Solr.cmd file.
- You will see this line – “IF “%SOLR_JAVA_MEM%”==”” set SOLR_JAVA_MEM=-Xms512m -Xmx512m”
- Comment the line by adding REM at the beginning.
- Add new line line below it – “IF “set SOLR_JAVA_MEM=-Xms1024m -Xmx1024m”
- Save the file and restart the service.
The links that I referred while troubleshooting are:
- https://sitecore.stackexchange.com/questions/8849/java-lang-outofmemoryerror-during-solr-index-rebuilding
- https://horizontal.blog/2016/04/09/solr-core-configuration-considerations/
Thank you.. Keep Learning.. Keep Sitecoring.. 🙂