Question

TL;DR

I have Apache Solr installed on Windows Server R2 64-bit machine with 8 GB of RAM. By default, JVM seems to be using ~256 MB of memory. Since I have some pretty big files for indexing with it, sometimes I get Java heap space OutOfMemoryError.

How should I increase the memory size available to Solr?

More details

Most of the documentation / posts I found over the web are pointing to something like java -Xms1024m -Xmx2048m -jar start.jar, but I'm not running the Solr through the command line. It's run as a Windows service. I guess there's a config option to set this somewhere in Solr installation folder, but I'm not able to find it (and besides, not very familiar with Java stack, since I'm a .NET developer).

Few things I tried:

  • setting environment variable in /Bitnami/solr-4.5.0-0/scripts/setenv.bat: set JAVA_OPTS="%JAVA_OPTS% -XX:MaxPermSize=1024m -Xms1024 -Xmx1024m"
  • modifying /Bitnami/solr-4.5.0-0/scripts/serviceinstall.bat and trying to add JvmOptions arguments to a command line for installing Jetty service (again, not familiar with syntax here). There's a similar answer for Ubuntu based installation, but script files are different.
  • running /Bitnami/solr-4.5.0-0/serviceinstall.bat REMOVE and serviceinstall.bat INSTALL after the changes above

Below is Solr's Dashboard screenshot.

Solr dashboard screenshot

Any idea?

Update 1

There's a serviceinstall.bat file in /Bitnami/solr-4.5.0-0/apache-solr/scripts/ which contains Jvm options which I tried modifying but failed to get the expected result. Here's that line from the file (added line breaks for better display):

"D:\BitNami\solr-4.5.0-0/apache-solr\scripts\prunsrv.exe" //IS//solrJetty 
--DisplayName="solrJetty" 
--Install="D:\BitNami\solr-4.5.0-0/apache-solr\scripts\prunsrv.exe" 
--LogPath="D:\BitNami\solr-4.5.0-0/apache-solr\logs" 
--LogLevel=Debug 
--StdOutput=auto 
--StdError=auto 
--StartMode=Java 
--StopMode=Java 
--Jvm=auto 
++JvmOptions=-DSTOP.PORT=8079 
++JvmOptions=-DSTOP.KEY=s3crEt 
++JvmOptions=-Djetty.home="D:\BitNami\solr-4.5.0-0/apache-solr" 
++JvmOptions=-Dsolr.solr.home="D:\BitNami\solr-4.5.0-0/apache-solr/solr" 
--Jvm=auto 
++JvmOptions=-Djetty.logs="D:\BitNami\solr-4.5.0-0/apache-solr\logs" 
--JavaHome="D:\BitNami\solr-4.5.0-0\java" 
++JvmOptions=-XX:MaxPermSize=128M 
--Classpath="D:\BitNami\solr-4.5.0-0/apache-solr\lib\*";"D:\BitNami\solr-4.5.0-0/apache-solr\start.jar" 
--StartClass=org.eclipse.jetty.start.Main 
++StartParams="D:\BitNami\solr-4.5.0-0/apache-solr\etc\jetty.xml" 
--StopClass=org.eclipse.jetty.start.Main 
++StopParams=--stop 
++StopParams=-DSTOP.PORT=8079 
++StopParams=-DSTOP.KEY=s3crEt

Does anyone know where to put additional JvmOptions (Xmx, Xms...) and what the syntax should be?

Was it helpful?

Solution

After some more research, I've managed to increase the heap size, by modifying /Bitnami/solr-4.5.0-0/apache-solr/scripts/serviceinstall.bat script according to @rchukh's comment.

I've tried modifying that file before, but the Solr service needs to be reinstalled after any change there. The problem was that I tried to reinstall it using the /Bitnami/solr-4.5.0-0/serviceinstall.bat. That batch script should be running all other serviceinstall.bat scripts in all subfolders, however it doesn't run the one that I needed.

So, here's how my /Bitnami/solr-4.5.0-0/apache-solr/scripts/serviceinstall.bat script looks now (longer lines broken for readability):

@echo off
rem -- Check if argument is INSTALL or REMOVE

if not ""%1"" == ""INSTALL"" goto remove

"D:\BitNami\solr-4.5.0-0/apache-solr\scripts\prunsrv.exe" //IS//solrJetty 
--DisplayName="solrJetty" 
--Install="D:\BitNami\solr-4.5.0-0/apache-solr\scripts\prunsrv.exe" 
--LogPath="D:\BitNami\solr-4.5.0-0/apache-solr\logs" 
--LogLevel=Debug 
--StdOutput=auto 
--StdError=auto 
--StartMode=Java 
--StopMode=Java 
--Jvm=auto 
++JvmOptions=-DSTOP.PORT=8079 
++JvmOptions=-DSTOP.KEY=s3crEt 
++JvmOptions=-Djetty.home="D:\BitNami\solr-4.5.0-0/apache-solr" 
++JvmOptions=-Dsolr.solr.home="D:\BitNami\solr-4.5.0-0/apache-solr/solr" 
--Jvm=auto 
++JvmOptions=-Djetty.logs="D:\BitNami\solr-4.5.0-0/apache-solr\logs" 
--JavaHome="D:\BitNami\solr-4.5.0-0\java" 
++JvmOptions=-XX:MaxPermSize=256M 
++JvmOptions=-Xms1024M 
++JvmOptions=-Xmx1024M 
--Classpath="D:\BitNami\solr-4.5.0-0/apache-solr\lib\*";
            "D:\BitNami\solr-4.5.0-0/apache-solr\start.jar" 
--StartClass=org.eclipse.jetty.start.Main 
++StartParams="D:\BitNami\solr-4.5.0-0/apache-solr\etc\jetty.xml" 
--StopClass=org.eclipse.jetty.start.Main 
++StopParams=--stop 
++StopParams=-DSTOP.PORT=8079 
++StopParams=-DSTOP.KEY=s3crEt

net start solrJetty >NUL
goto end

:remove
rem -- STOP SERVICE BEFORE REMOVING

net stop solrJetty >NUL
sc delete solrJetty

:end
exit

After that script is modified, you need to reinstall the service by running it twice (to remove and install):

D:/Bitnami/solr-4.5.0-0/apache-solr/scripts/serviceinstall.bat REMOVE
D:/Bitnami/solr-4.5.0-0/apache-solr/scripts/serviceinstall.bat INSTALL

OTHER TIPS

You can change Bitnami\solr-5.2.1-1\apache-solr\bin\solr.in.cmd . There is a line that says :

set SOLR_JAVA_MEM=-Xms512m -Xmx512m

Change that to

set SOLR_JAVA_MEM=-Xms2g -Xmx2g

Then you need to restart the service :

net stop solrJetty 
net start solrJetty 

go to : http://localhost:8983/solr/#/ You will see new values in effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top