DHIS2- TompCat Issue(Java heap space) caused by out of memeory error

Sir,
While running DHIS-2 Application. My tomcat give out of memory issue several times a day. After that dhis2 stop running there functionality. I have to restart tomcat again to work properly.

How to handle that issue ?

Which Java version?

···

On Thu, Aug 17, 2017 at 7:11 AM, Omer Butt omerbutt2521@gmail.com wrote:

Sir,
While running DHIS-2 Application. My tomcat give out of memory issue several times a day. After that dhis2 stop running there functionality. I have to restart tomcat again to work properly.

How to handle that issue ?


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Knut Staring

Dept. of Informatics, University of Oslo

Norway: +4791880522

Skype: knutstar

http://dhis2.org

Try allocating more memory to Java by creating an environment variable called
JAVA_OPTS and set it to -Xmx512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m

···

On Thu, Aug 17, 2017 at 7:11 AM, Omer Butt omerbutt2521@gmail.com wrote:

Sir,
While running DHIS-2 Application. My tomcat give out of memory issue several times a day. After that dhis2 stop running there functionality. I have to restart tomcat again to work properly.

How to handle that issue ?


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp


Knut Staring

Dept. of Informatics, University of Oslo

Norway: +4791880522

Skype: knutstar

http://dhis2.org

I have my variable as

Variable Name: JAVA_OPTS
Value: -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=768m
and I’m still experiencing the error.

Can I go higher? I’m working on a 16GB RAM, 1 TB memory & i7-8550U CPU @ 1.80GHz 1.99 GHz Processor

Yes, you clearly have the resources to go much higher.

Any specific recommendations for the figures I should use for the variable?

You can experiment a bit, but perhaps try doubling, and if that doesn’t work, double again.

So e.g.: -Xms1024m -Xmx2048m

Actually, the documentation suggests much higher numbers -Xms4000m -Xmx7000m.

Also, since you are using Java 1.8, you can just remove the last two parameters, as they no longer apply (i.e. just delete this part: -XX:PermSize=256m -XX:MaxPermSize=768m)


So after changing the OPTS variable to the recommended amount in the documentation … I’m still having trouble running a process on DHIS.

I think we need input from other experts here. The 4000/7000 settings probably don’t really make sense with a 32-bit JRE, though, so maybe you should try again with the 64-bit one.

Maybe this link can be helpful, it introduces another set of parameters also:

I have a java heap space error (http status 500) as well and I’m trying to figure out how high I can go on my JAVA_OPTS? I’m on 16GB ram.

Hi @lillian1n2,

May I ask if you were able to solve the issue? Thank you!

I’ve been trying to export to do backup of work done and replicate the work on a different server and I’ve been running into HTTP Status 500 - Internal Error Server saying java heap space memory…

How could you identify it was a firewall issue? I’m on a 16GB RAM and Java 1.8 with OPTS being at 4000 and 7000 as recommended in the documentation.

Hi! I’m still working on it and no I haven’t…

What issues may using 32bit Java cause? I’m running my JRE on 32bit because I really struggled successfully installing a local on my windows machine and A JRE on 32bit and corresponding Apache Service on 32bit seemed to do the trick for me…

Though I’ve been adding org units (tens of thousands) to my local in the past week and the system has really lagged behind… I’ve had to keep restarting the service to get work done.

One limitation of 32bit is that it limits the RAM that can be accessed: How much RAM does your PC really need? | ZDNet

Actually my OS is 64bit so I’m a bit confused…

Here are my DHIS components that I am working with:
PostgreSQL 12 - 64bit
JDK 13 - 64bit
JRE 1.8.0_301 - 32bit
Apache 9 Service Installer - 32 bit

DHIS 2.35.6

So I had initially struggled getting a local instance up and running until this combination worked (I’d been installing the latest versions of components apart from DHIS and all 64bit)

Now I’m trying to run processes and exports on my local instance and running out of space with the HTTP Status 500 Error and I’m trying to find a solution…

Hello Lillian,

To begin with, what type of installation you did, What I mean, did you use the ng-tools (Apache2) or maybe the Nginx and finally the standalone manual drove. That will help determine where the problem might be coming from.
if all this has been determined, clear the logs in the catalina.out or if you used the ng-tools in the /opt/dhis2/logs there is a log file in there. clear the logs and start the instance and share fresh logs in zip and upload them here.

Then we would have identified the problem and it will be resolved in no time.

Kind regards
Moses

1 Like

I don’t have much experience on windows and 32 bit java. Quick thoughts:

  1. you should use definitely use 64 bit
  2. Use java 11 rather than java 8 (or 13)
  3. The amount of heap space you can allocate for java is not really something you can get from the documentation. It depends a lot on what else is running on your machine and what load you expect on your DHIS2. But your initial settings are certainly too low. I would suggest trying:

-Xms4096m -Xmx4096m

(on a server we typically make the max and the min amounts the same)

Is this meant to be for a production setup on the web, or just something you are trying on your laptop? For production setup there are many other things to consider.

Regards
Bob

1 Like

I did the installation by downloading the individual components then just copying the .war file into the webapps folder and deploying it.

PostgreSQL 12 - 64bit
JDK 13 - 64bit
JRE 1.8.0_301 - 32bit
Apache 9 Service Installer - 32 bit

When I tried to install the 64bit versions, it actually never successfully deployed. So the 32bit was something I worked out with my colleague and it seemed to do the trick. There were actually no issues and the instance was stable up until I noticed the more I worked on it, it would slow down.

I’m also not quite sure I understand you in your initial statement - ‘What I mean, did you use the ng-tools (Apache2) or maybe the Nginx and finally the standalone manual drove.’. Maybe you could provide me with further elaboration.

How do I clear the logs in the catalina.out file? I simply erase everything?

Thanks again for your help with this matter.

Hey Bob,

So I have another laptop with slightly different specs and a running DHIS2 instance on there. I have set up 64 bit java… and java 13 over 11 (before I had seen this reply).
Thanks for the rec on the heap space, i’ll adjust accordingly and come back to this thread.

This is actually for a test environment or rather local environment for testing and configuration. I tend to do the work here, then export and import onto the production server when it works well.

What else would I consider with production if it were the case?