2. <Insert Picture Here>
Memory Leak Profiling with NetBeans and HotSpot
Clarence J M Tauro
Senior Curriculum Developer, Oracle ST Java Curriculum
3. Session Agenda
• About the Speaker <Insert Picture Here>
• Different aspects of Performance
• Memory leaks and profiling
• Demo
3
4. About the Speaker
• Clarence J M Tauro – clarence.tauro@oracle.com
• Senior Curriculum Developer, Java Curriculum (Oracle ST Curriculum)
• ~7 Years Professional Teaching and Instructional Design Experience
• Masters of Science in Information Technology
• Masters of Technology in Computer Science
• Masters of Philosophy in Computer Science
• Doctor of Philosophy in Computer Science [expected to graduate by August 2012]
• Guest faculty to various Colleges and Universities
4
5. Different Aspects of Performance
In this talk we will look
at memory profiling
Memory footprint
Throughput Performance Aspects Scalability
Responsiveness
5
6. Memory Leak Profiling: Why and When
• Memory leaks are situations where a reference to allocated objects
remains unintentionally reachable and as a result cannot be garbage
collected.
– Leads to poor application performance
– Can lead to application failure
– Can be hard to diagnose
6
9. Profiling
• An act of collecting or observing performance data from an operating or
running application.
• Usually more intrusive than monitoring.
• Usually a narrower focus than monitoring.
9
12. DEMO – NetBeans Profiler Configuration
I am interested in
Garbage collection
statistics too
Choosing this option
has a lot of additional
overhead
12
19. DEMO – Source of
____________JavaScript.clearErrorMessages()
19
20. DEMO – Find Usages on -----------------------------------------
--------------------JavaScript.clearErrorMessages()
So, who calls the JavaScriptEngineFactory.clearErrorMessages()??
20
21. DEMO – Find Usages on
JavaScriptEngineFactory.clearErrorMessages(
)
So, who calls the HttpUnitOptions.clearScriptErrorMessages()??
21
22. DEMO – Find Usages on
HttpUnitOptions.clearScriptErrorMessages()
Ahh.. Haa.. You just found the root cause of the memory leak.
The _errorMessages ArrayList is NEVER cleared.. It has only elements added to it.
22
23. Farewell to the memory leak!
So, to fix this memory leak, the ArrayList needs to be explicitly cleared.
This is a task for the authors of HttpUnit
23
24. Where to go?
• Java Performance Tuning and Optimization Course from
Oracle University
• Java Performance - Charlie Hunt (Author), Binu John (Author) (Expected
August 2011)
24