Tomcat memory issue

Tomcat memory issue

Introduction

This article explains how to resolve memory-related task failures in 360Suite when the Tomcat Java Virtual Machine runs out of memory or exceeds garbage collection overhead limits.

Environment

  • Product: 360Suite
  • Operating systems: Windows or Linux

Symptoms

  • A 360Suite task fails with a memory-related error.
  • The error appears in the task logs or Tomcat logs.

Error Message

Warning
java.lang.OutOfMemoryError: GC overhead limit exceeded

Cause

The garbage collector is spending too much time attempting to reclaim memory without successfully freeing enough space. This indicates that the maximum heap size allocated to Tomcat is insufficient for the task.

Resolution

Increase the maximum memory (heap size) allocated to Tomcat. The specific adjustment depends on your server's available memory and the size of the dataset being processed.

Windows environment 

This has to be done in the Tomcat Configuration tool. 

This tool can be found in the 360Suite installation folder (next to the apache-tomcat folder) if you are using the tomcat we deliver with 360Suite.
In other cases (third-party tomcat or BOBJ tomcat), this tool is also available because it is installed alongside the tomcat itself. It should be accessible via the Windows start menu.
  1. Open the Tomcat Configuration as Administrator
  2. Go to the Java tab
  3. In the Maximum memory pool section you can change the maximum amount of memory allocated to the tomcat (this adjustment must be done according to the server memory capacity)
  4. Click “apply” then restart the tomcat 


Linux environment

On a Linux server, the memory settings for Apache Tomcat can be added or modified in the file where the environment variables are configured.

Typically, in <apache-tomcat>/bin/setenv.sh or another “.sh” file (in the bin directory) that is used by default to start the tomcat. Several parameters for the memory values can be set here but the most important is -Xmx that defines the maximum memory size. It can be set with either a megabytes value (m) or a gigabytes value (g)

Example : 
Quote
CATALINA_OPTS="-Xms4g -Xmx12g -Xss-256k"

Quote
JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=1024m"

For more details about this Linux Tomcat configuration, please refer to the offical Apache Tomcat documentation.
A Tomcat restart is necessary after this change.