IBM Support

Preventing mark stack overflows during garbage collection in the Java SDK

Troubleshooting


Problem

In the Java™ SDK shipped for AIX®, Linux® and Windows®, the mark stack is created during the first phase of garbage collection when live objects are marked for retention. Objects are taken off the stack and any references held by the object are added. Mark stack overflow in itself does not indicate an error condition, but it does result in increased CPU utilization.

Cause

Mark stack overflow can be caused because the mark stack is finite.

Resolving The Problem

There is no way to totally avoid a mark stack overflow if you have deep, wide object trees. The following suggestions are not guaranteed to avoid mark stack overflow:

Reducing the Java maximum heap size or the number of objects allocated might help. Any mark stack overflow results in a scan of the entire Java heap, which is expensive in terms of CPU utilization. So, if heap is not occupied to the full extent, the recommendation is to reduce the Xmx to eliminate or minimize mark stack overflow.

Additionally, adding the following Java Virtual Machine (JVM™) argument might help address mark stack overflows:

-Xgcpolicy:optavgpause

This reduces and makes pause times more consistent when the heap occupancy rises. However, it also reduces throughput by approximately 5% depending on the application.

Increasing the number of CPUs on a system also helps address mark stack overflows by taking advantage of parallel garbage collection through gc helper threads. On a system with n processors, the default setting for -Xgcthreads is n - 1 when in resettable mode and n when not in resettable mode. This option sets the number of helper threads that the Garbage Collector uses for concurrent operations.



For more information on mark stack overflows, refer to the IBM Developer Kit and Runtime Environment Java 2 Technology Edition Diagnostics Guide.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Out of Memory","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.0;7.0","Edition":"Base;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21164724