Menu

What Does Sitecore Do

java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space in Sitecore Solr engine

HttpSolrCall java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space => java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:743) in Solr engine Sitecore

Due to this Solr engine stops working in production servers cm, cd1 & cd2 while it shows in running in windows services. This error is usually caused by Solr running out of memory.

It tried to analyse the logs and figure it outof memorry error in solr module. log location “sorl directory/server/logs”. Little bit research I found the solr article to increase the heap size of solr ram usage.

Increasing the heap size can help prevent Solr from stopping unexpectedly due to memory issues, especially when dealing with large indexes or high query loads.

Steps to Configure Heap Size in Solr for Sitecore:

1. Locate Solr Installation Directory:
– First, navigate to your Solr installation directory. Typically, Solr is installed in a path like `C:\Solr\` on Windows or `/opt/solr/` on Linux systems.

2. Locate the Solr Configuration File:
– For Solr running as a service, you will need to modify the Solr service configuration file.
– On Windows, find the file `solr.in.cmd` located in the `bin` directory of your Solr installation.
– On Linux, find the file `solr.in.sh` located in the `/opt/solr/bin/` directory.

3. Edit Heap Size Configuration:
– Open the `solr.in.cmd` (for Windows) or `solr.in.sh` (for Linux) file in a text editor.

– Look for the following lines (or similar) in the configuration file:

 

Default heap size in sitecore 10:

SOLR_JAVA_MEM=”-Xms512m -Xmx512m”

need to increase as below

# Increase the heap size for Solr (example values)
SOLR_JAVA_MEM=”-Xms512m -Xmx1024m”

– Here:
– `-Xms` is the initial heap size.
– `-Xmx` is the maximum heap size.

4. Adjust Heap Size:
– Modify the values of `-Xms` and `-Xmx` to allocate more memory depending on your system resources. For example:

SOLR_JAVA_MEM=”-Xms1024 -Xmx4096m”

– This will set the initial heap size to 1GB and the maximum heap size to 4GB.
– Be cautious not to allocate more memory than your system can handle. Typically, setting it to about 50% of your available system memory is a good starting point.

5. Save and Restart Solr:
– After making the changes, save the configuration file.
– Restart the Solr service to apply the new heap size settings:
– On Windows:
– You can restart Solr by opening a command prompt as an administrator and running:

net stop solr
net start solr

– On Linux:
– Use the following command to restart Solr:
bash
sudo service solr restart

Set heap in `solr.in.cmd` Configuration (for Windows):

Set the heap size for Solr minimum 512m to 1024m
set SOLR_JAVA_MEM=-Xms512m -Xmx1024m

Restart the the solr engine and check the solr dashboard JVM Memory.

Solr-engine- heap-size-increase

By adjusting the heap size and tuning Solr appropriately, you can help avoid unexpected stops and crashes, ensuring more stable Solr performance in Sitecore environments.