I admit I had to wrestle with this one a bit more than I wanted to. In my case I needed to set the memory for a Solr instance I was running that was maxing out on memory, and it was being initiated through an NSSM service. Passing on the required parameters to the java executable wasn’t really an option for what I was doing. From there people suggested setting through the Configure Java window and setting the parameters there, nope, no luck for me. From there I tried setting the JAVA_OPTS variable in the Environment Variables but still no luck.
Finally I found a lesser upvoted answer on stack overflow that was what I actually needed. I had to create a Windows System Environment variable called _JAVA_OPTIONS, not JAVA_OPTS and then for the value I put:
-Xms1024m -Xms2048m
After I restarted a quick look at the Solr dashboard told me the settings had finally taken effect:
So if you’re having trouble setting the JVM memory using the standard methods, and you’re also having the JVM started behind the scenes by another application and can’t pass a variable into the command line, try using the _JAVA_OPTIONS variable instead.
A seasoned Senior Solutions Architect with 20 years of experience in technology design and implementation. Renowned for innovative solutions and strategic insights, he excels in driving complex projects to success. Outside work, he is a passionate fisherman and fish keeper, specializing in planted tanks.