Configuring the memory leak policy
The leak detection policy for the WebSphere® Application Server is turned off by default. You can configure a leak detection, prevention, and action policy to accommodate your applications and environment so that potential memory leaks are reported and acted upon. Leak detection, prevention, and proactive fixing provides for protection and resiliency for servers that face persistent out of memory errors. When a classloader memory leak is detected, WebSphere® Application Server notifies you with informational messages in the log and by taking JVM heapdumps so that you can troubleshoot the problem. Optionally, you might also choose to have WebSphere Application Server mitigate, and if possible, fix the memory leak using reflection and other techniques.
Before you begin
A common error in Java™ Platform, Enterprise Edition (Java EE) applications is a classloader memory leak. A memory leak can result from subtle application bugs or a more complex use, such as third party libraries. System resources, such as CPU time due to garbage collection and the Java heap are consumed when a leak is present. A system can become unresponsive even though all other resources are available. Unless a protection and early warning system is built in, the system might remain in this degraded state and ultimately die due to an out of memory error.
About this task
All persistent configurations of this service are completed using JVM custom properties. There are no administrative console panels. At runtime, use the MemoryLeakConfig and MemoryLeakAdmin mbeans for configuration and administration respectively; however, the configuration changes are not persisted until JVM custom properties are configured.
The MemoryLeak service and its mbean are active only in an application server that hosts applications and services requests. This service is not active on a Deployment Manager, node agent, administrative agent, or other servers types like WebSphere proxy server and so on.
Procedure
Example
The Memory Leak policy for WebSphere Application Server can be configured and persisted using JVM custom properties as described in this example. At runtime the memory leak detection, prevention and policy configuration can be changed using the MemoryLeakConfig mbean.
Administration of the Memory leak policy can be carried out using the MemoryLeakAdmin mbean. The leak policy affects how the application server responds to a classloader memory leak when an application or when the server is stopped.
# Scripting in JACL
# Get the object name of the MemoryLeak Configiration object you want to change the values on
set leakConfig [$AdminControl completeObjectName "type=MemoryLeakConfig,*"]
WebSphere:cell=smitaNode03Cell,name=LeakConfig,type=MemoryLeakConfig,node=smitaNode03,process=server1
# Get the object name of the MemoryLeak Administration object you want to issue operations
set leakAdmin [$AdminControl completeObjectName "type=MemoryLeakAdmin,*"]
WebSphere:cell=smitaNode03Cell,name=LeakAdmin,type=MemoryLeakAdmin,node=smitaNode03,process=server1
# Look at all the attributes of the MemoryLeakConfig mbean
wsadmin>$Help all $leakConfig
Name: WebSphere:cell=smitaNode03Cell,name=LeakConfig,type=MemoryLeakConfig,node=smitaNode03,process=server1
Description: Information on the management interface of the MBean
Class name: com.ibm.ws.runtime.component.MemoryLeakConfig
Attribute Type Access
JvmThreadGroupNames java.lang.String RW
FilterPrefixes java.lang.String RW
RenewThreadPoolNames java.lang.String RW
DetectAppCLLeaks boolean RW
ClearAppCLLeaks boolean RW
MonitorSystemApps boolean RW
NoDumps boolean RW
GenerateHeapDumps boolean RW
GenerateSystemDumps boolean RW
ClearReferencesStatic boolean RW
ClearReferencesInterruptThreads boolean RW
ClearReferencesStopTimerThreads boolean RW
ClearReferencesHttpClientKeepAliveThread boolean RW
ClearReferencesThreadLocal boolean RW
LeakSweeperDelay int RW
ThreadPoolRenewalDelayFactor int RW
PreventJreMemoryLeaks boolean RW
LeakConfiguration java.lang.String RO
Operation
Notifications
Constructors
# Print the current Memory Leak Policy configuration on the console
wsadmin>$AdminControl getAttribute $leakConfig LeakConfiguration
MemoryLeakConfig [getClass()=class com.ibm.ws.runtime.component.MemoryLeakConfig, hashCode()=37266644
preventJreMemoryLeaks true
detectAppCLLeaks true
monitorSystemApps false
leakSweeperDelay 10000
clearAppCLLeaks true
clearReferencesStopTimerThreads false
clearReferencesHttpClientKeepAliveThread true
clearReferencesInterruptThreads true
jvmThreadGroupNames [system, RMI Runtime]
clearReferencesStatic true
filterPrefixes [java., javax., com.ibm., org., sun., com.sun]
clearReferencesThreadLocal true
renewThreadPoolNames [WebContainer]
threadPoolRenewalDelayFactor 1
noDumps false
generateHeapDumps true
generateSystemDumps false
# Change the configuration
wsadmin>$AdminControl setAttribute $leakConfig ThreadPoolRenewalDelayFactor 10
wsadmin>$AdminControl setAttribute $leakConfig ClearReferencesStopTimerThreads true
# See the updated configuration
wsadmin>$AdminControl getAttribute $leakConfig LeakConfiguration
MemoryLeakConfig [getClass()=class com.ibm.ws.runtime.component.MemoryLeakConfig, hashCode()=37266644
preventJreMemoryLeaks true
detectAppCLLeaks true
monitorSystemApps false
leakSweeperDelay 10000
clearAppCLLeaks true
clearReferencesStopTimerThreads true
clearReferencesHttpClientKeepAliveThread true
clearReferencesInterruptThreads true
jvmThreadGroupNames [system, RMI Runtime]
clearReferencesStatic true
filterPrefixes [java., javax., com.ibm., org., sun., com.sun]
clearReferencesThreadLocal true
renewThreadPoolNames [WebContainer]
threadPoolRenewalDelayFactor 10
noDumps false
generateHeapDumps true
generateSystemDumps false
# Look at all the operations of the MemoryLeakAdmin mbean
wsadmin>$Help all $leakAdmin
Name: WebSphere:cell=smitaNode03Cell,name=LeakAdmin,type=MemoryLeakAdmin,node=smitaNode03,process=server1
Description: Information on the management interface of the MBean
Class name: com.ibm.ws.runtime.component.MemoryLeakAdmin
Operation
java.lang.String findLeaks()
java.lang.String fixLeaks()
java.lang.String fixLeaks(java.lang.String)
# Find current classloader memory leaks
wsadmin>$AdminControl invoke $leakAdmin findLeaks
CWMML0028I: The following web applications were stopped (reloaded, undeployed),
but their classes from previous runs are still loaded in memory,
thus causing a memory leak.[[78577.075.724.NWALogging#NWALoggingEJB.jar]].
# Fix ALL current classloader memory leaks
wsadmin>$AdminControl invoke $leakAdmin fixLeaks
CWMML0036I: Please watch the SystemOut log for results of the fix leak operation.
wsadmin>$AdminControl invoke $leakAdmin fixLeaks {"78577.075.724.NWALogging#NWALoggingEJB.jar"}
CWMML0036I: Please watch the SystemOut log for results of the fix leak operation.