How much memory DHIS need? Permanent OutOfMemoryError

Logs:
SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcher] in context with path [/dhis] threw exception [Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space] with root cause java.lang.OutOfMemoryError: Java heap space

Detalis:
Windows Server 2016; RAM 512 GB (server isn’t used only for DHIS),
apache-tomcat-9.0.63
dhis2-stable-2.38.0
jdk-18.0.1.1 (x64)

I’m constantly increasing the memory size, now it is:
JAVA_OPTS: -Xms75000m -Xmx100000m -XX:PermSize=2048m -XX:MaxPermSize=2048m.

What are the optimal parameters for JAVA_OPTS?

Hi @vplesca,

Please check the Catalina.out log file, would you share it with us (without the sensitive info)? Please check if there any tables that need to be dropped or taking too much space.

Thank you!

On server I have 512GB and a “lot” of is free. Problem is where I need to change settings somehow/somewhere?

I didn’t change the Tomcat parameters. PostgreSQL settings changed according with this guide

This is not a migration, just first/initial installation

DHIS2 is just installed.

@Gassim - log file is attached, but I can’t upload log/text files => copied/transformed in “.doc”
catalina.2022-05-19.doc (60.5 KB)

@vplesca ,

From the log you shared, I can see that your heap size is too small. You are likely setting JAVA_OPTs in the wrong place.

19-May-2022 22:09:35.655 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
19-May-2022 22:09:35.655 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m

It is difficult to answer your question about how much memory DHIS2 needs without knowing your implementation size and load patterns. Some implementations have it as low as 5g, some as high as 64g.

1 Like

@Gintare, Please have a look to the image. DHIS2 can read JAVA_OPT.


Maybe the format is wrong and You can help?

The format looks correct to me, but these opts are not picked up - you can see max limit set to 256 (m) in “Memory info” row. Where do you set these? System variables/tomcat startup file?

Gintare

@Gintare: I’m not a Tomcat specialist, I didn’t change anything during the installation.

1 Like

@Gintare: I changed the postgreSQL settings according to this guide.

Valeriu

1 Like

I suggest taking a look at this guide then. It should have you covered on how and where to set java_opts. Alternatively, you could find resources online specific to windows server.

@Gintare & @Gassim:
1) Last version of Java (18 in my case) not understand parameters “-XX:PermSize=… -XX:MaxPermSize=…” as in this guide indicated
2) My actual JAVA_OPTS: -Xms4096m -Xmx8192m -server
3) Tu run Tomcat I am using “…\Tomcat 9.0\bin\startup.bat”, but not “Tomcat9.exe” (contrary guide indications)
4) “startup.bat” permanent say something like “JRE_HOME” is not correct…bla…bla… and I created the file “setenv.bat” with:
set “JAVA_OPTS=-Xms4096m -Xmx8192m -server”
set “JAVA_HOME=C:\Program Files\Java\jdk-18.0.1.1”
set “JRE_HOME=C:\Program Files\Java\jdk-18.0.1.1”
exit/b 0
5) Used memory must be indicated separately for Windows service (Tomcat9w.exe) like in picture:
Tomcat-service-settings

2 Likes

Great, thank you for sharing the solution with the community! :+1: