Memory use increases over time

The amount of memory used by the Gateway daemon might increase over time and a java.lang.OutOfMemory exception might occur.

The maximum number of connection manager threads and worker threads is defined in the CICS® Transaction Gateway configuration.

Symptom

The Gateway daemon stops responding and the JVM writes a java.lang.OutOfMemory exception to the stderror log file or to the Java™ dump file. The JVM also creates various dump files in the information log. There is probably no noticeable decrease in performance before the problem occurs. If you happened to be monitoring memory usage before the dump occurred, you would have seen that memory usage gradually increased over time until eventually the limit was reached.

Probable cause

  • There is a problem with a user-written application, for example a request exit which has remained inadvertently connected and is using Java resources.
  • There are too many active Java threads (connection manager threads and worker threads).
  • The Java heap size is unnecessarily large. Because the memory required to create Java heap and Java threads is allocated from the same finite storage area, it is possible that making the Java heap too large could indirectly cause a java.lang.OutOfMemory exception because there would then be insufficient memory available to create enough Java threads.
  • The Java heap size is too small.
  • The CICS REGION size is too small.

Action

  • If there is a problem with a user application, ensure that the application practices good memory management techniques, such as freeing resources when they are no longer required.
  • If the Java heap size is unnecessarily large or too small, set the maximum amount of heap memory available to the JVM by using the -Xmx option. The default heap size specified by the CICS Transaction Gateway is 128MB.
  • Run a memory usage monitor against the Gateway daemon process.

Additional information

The way that Java allocates memory depends on your JVM implementation. Most JVMs allow you to adjust the maximum amount of heap memory and adjust the amount of memory allocated to each thread.

The amount of memory that Java allocates to each thread is set by using the -Xmso and -Xss options. Do not change the Java stack and native stack sizes from their default values.

For more information on thread limits see Threading model. For more information on Java memory allocation and JVM stack sizes, see the IBM® Java Diagnostics Guides Information Center.

Also see Tuning the Gateway to avoid out-of-memory conditions.