WebSphere Application Server V8.5 Operations and Control
Part 3: Memory Leak Detection and Correction 1 Copy logger.exe from the Lab4 folder to
C:\IBM\WebSphere\AppServer\profiles\AppServer01\logs\server1
____ 2. logger is a utility for Windows that provides the Unix “tail” function. Open a command window for the C:\IBM\WebSphere\AppServer\profiles\AppServer01\logs\server1 directory and enter the command logger.exe SystemOut.log
The SystemOut.log will then scroll as you make changes in this lab.
Minimize but DO NOT CLOSE this command window, we will return to it later in the lab
Install a test application that will produce a Java memory leak.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators
____ 4. Click on New Enterprise Application
____ 5. Using the Local file system option, browse to the location where you placed the LeakApp.ear. Click open then click Next.
The instructor has provided the LeakAppEar.ear file as part of this lab exercise.
____ 6. Use the Fast path option and click Next
____ 8. Accept the default values on the Map modules to server panel and click Next
____ 9. Accept the default values on the Map virtual hosts for Web modules panel and click Next
____ 10. Accept the default values on the Metadata for modules panel and click Next
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators
____ 12. When the application has been successfully installed, click Save
Start the Memory Leak Application
____ 13. Check to see that the application is started by navigating to Applications -> Application Types , expand Application Types, click on WebSphere enterprise applications,
To start the LeakAppEar, select the checkbox to the left of the application name and click the Start buttonas shown below.
Note: There are two options for configuring memory leak detection, application server configuration changes which are persisted to the application server configuration and application server runtime changes.
Configuration changes are permanent and apply each time the application server is started (and require a server restart to become effective)
Runtime changes are not permanent and need to be made each time an application server is started. In order to speed delivery of this lab the memory leak detection function will be enabled using runtime changes using wsadmin to update the Mbeans associated with this function. The instructions for using configuration changes to permanently update the configuration is provided in Appendix A
Enable the Leak Detection feature using the wsadmin commands.
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.
You will explore several of the capabilities of the memory leak detection and mitigation in this section of the exercise.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators
Ensure you are in the following directory in the command prompt: C:\IBM\WebSphere\AppServer\profiles\AppServer01\bin
__ a. when prompted, enter wasadmin for the user and wasadm1n for the password.
__ b. Since this is the first time the wsadmin jython libraries have been used you’ll see a number of messages similar to those shown below. indicating *sys-package-mgr*: processing new jar, <jar name> “
____ 15. Obtain a reference to the memory leak configuration Mbean using the following command: leakconfig = AdminControl.completeObjectName('type=MemoryLeakConfig,*')
TIP: You need a reference to the memory leak Configuration MBean in order to execute the configuration
commands that are listed on step 19, that influence the configuration of the memory leak configuration. ____ 16. Check to see the reference that was returned using the following command
print leakconfig
____ 17. Obtain a reference to the memory leak administrativeMbean using the following command leakadmin = AdminControl.completeObjectName('type=MemoryLeakAdmin,*')
TIP: You need a reference to the memory leak Administrative MBean in order to execute the administrative commands listed in step 20.
____ 18. Check to see the reference that was obtained using the following command print leakadmin
____ 19. Look at the current configuration of the configuration Mbean using the following command. These are the attributes that can be set to influence the configuration.
print Help.all(leakconfig)
____ 20. Look at the current configuration of the administrative Mbean using the command. These are the attributes that can be set to influence the configuration.
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators
print Help.all(leakadmin)
____ 21. Enter the following wsadmin command to tell WAS to stop any Timer threads the application is started by an application.
AdminControl.setAttribute(leakconfig,'ClearReferencesStopTimerThreads','true')
TIP: Set the value to true for WebSphere Application Server to stop any java.util.TimerThreads that is started by the web application.
____ 22. Enter the wsadmin command to ensure that the value for this attribute was updated. AdminControl.getAttribute(leakconfig,'ClearReferencesStopTimerThreads')
____ 23. Enter the following wsadmin command to detect Class Loader leaks in applications. AdminControl.setAttribute(leakconfig,'DetectAppCLLeaks','true')
TIP: When the server is shutting down or an application stops, WebSphere Application Server determines
the classloaders that have leaked and issues warnings and other additional information that aids in debugging the memory leak.
____ 24. Enter the wsadmin command to ensure that the value for this attribute was updated AdminControl.getAttribute(leakconfig,'DetectAppCLLeaks')
____ 25. Enter the following wsadmin command to detect Thread Local leaks. AdminControl.setAttribute(leakconfig,'CheckThreadLocalLeaks','true')
TIP: Checks for ThreadLocal leaks when an application stops.
____ 26. Enter the wsadmin command to ensure that the value for this attribute was updated AdminControl.getAttribute(leakconfig,'CheckThreadLocalLeaks')
____ 27. Enter the following wsadmin command to enable WebSphere proactive leak mediation. AdminControl.setAttribute(leakconfig,'ClearAppCLLeaks','true')
TIP: This enables proactive classloader leak mediation and fixing. When this property is set to true,
WebSphere Application Server mediates on behalf of the application to remedy any classloader leaks that are detected.
____ 28. Enter the command to ensure that the value for this attribute was changed AdminControl.getAttribute(leakconfig,'ClearAppCLLeaks')
____ 29. Enter the following wsadmin command to check for memory leaks. (note that no leaks are found) AdminControl.invoke(leakadmin, 'findLeaks')
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators
____ 31. Refresh the URL several times
The application is designed to leak classes. The memory leak will be very slow and may not be noticeable, even after executing the leaking applications several times.
Note: Application stop is required because only when an application is stopped, is the memory leak function able to insure that the classloader of the application/module is no longer needed.
____ 32. Enter the wsadmin command to attempt to fix the memory leak and reclaiming memory that has been leaked by the application.
AdminControl.invoke(leakadmin, 'fixLeaks')
WARNING:
At the time of this writing, using WAS 8.5.0.0, the fixLeaks command does not seem to attempt to fix any leaks. However, upon stopping the leaking application, WebSphere detects the memory leaks and
reports them in the SystemOut.log.
Furthermore, the findLeaks command only seems to fin the memory leaks once the application has been stopped.
So, in order to see the memory leak, you will stop the leaking application, and review the SystemOut.log. ____ 33. From the WebSphere Admin Console, stop the LeakAppEar, by selecting the application and clicking
the Stop button. (using the same process you did to start the application)
Note: Application stop is required because only when an application stopped, is the memory leak function able to insure that the classloader of the application/module is no longer needed
Depending on the underlying cause of the memory leak, the “fixleaks” method, may or may not be able to provide a remedy. Memory leaks caused by incorrect use of Threadlocals, Timers, Threads, static
variables may be correctable by calling standard Java APIs or to use reflection to null out references or by stopping timers, interrupting threads or refreshing the thread pool. Other leaks related to the object references on the classloader on the other hand, may only be correctable by stopping the application.
____ 34. Stopping the application will result in the following types of messages in the SystemOut.log
____ 35. Notice that stopping the leaking application caused the memory leak detection function to realize that classes used by the application were not cleaned up, ev3en when the application stopped. This is a class loader memory leak.
__ a. You will also notice that the memory leak function produced Java heap dumps, which can be analyzed by the systems administrator and development team during problem determination.
End of Lab 4 – Congratulations!
You have successfully performed a silent install of Java 7 SE and configured WebSphere Application Server to use Java 7 using the managesdk command, used delta checkpoints to determine configuration changes, and
Discovering the value of IBM WebSphere Application Server V8.5 for Administrators