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?
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:
/Bitnami/solr-4.5.0-0/scripts/setenv.bat
: set JAVA_OPTS="%JAVA_OPTS% -XX:MaxPermSize=1024m -Xms1024
-Xmx1024m"
/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./Bitnami/solr-4.5.0-0/serviceinstall.bat REMOVE
and serviceinstall.bat INSTALL
after the changes aboveBelow is Solr's Dashboard screenshot.
Any idea?
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?
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