Search code examples
javatomcatjvmsap-commerce-cloud

SAP Hybris - Tomcat ignoring memory settings


I'm running a local installation of SAP Hybris 1811. I'm trying to increase its memory size since I've been getting OutOfMemory exceptions during SOLR index jobs.

However, I'm not able to reliably increase the memory via any method I've tried. Sometimes after struggling a lot (building the app multiple times, restarting, etc.) Hybris is able to see and use the set memory (I check this using backoffice), but most of the time it defaults to 2 GB and runs out of memory quickly.

What I've tried:

  • set JAVA_OPTS=-Xms10G -Xmx10G; in catalina.bat
  • tomcat.javaoptions=-Xmx10G -Xms10G in local.properties

What is the correct way to reliably set a higher memory for local Hybris server?


Solution

  • After a bit of digging, I found that the memory limit was ignored only when I've tried to run Hybris server with the debug parameter. I discovered that the properties I've tried to set using tomcat.javaoptions were not in the wrapper-debug.conf file which is used when starting the server in debug mode.

    Long story short:

    tomcat.javaoptions only gets applied to the default wrapper.conf file and is ignored when launching the server with any parameter such as debug.

    For the changes to be applied to the wrapper-debug.conf, I needed to use tomcat.debugjavaoptions property.

    In the end, my config file with working memory limit looks like this:

    ...
    tomcat.javaoptions=-Xmx10G -Xms5G
    tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n -Xmx10G -Xms5G