Memory Leak Profiling with NetBeans and HotSpot
-
Upload
javapsyche -
Category
Education
-
view
752 -
download
2
Transcript of Memory Leak Profiling with NetBeans and HotSpot
1
<Insert Picture Here>
Memory Leak Profiling with NetBeans and HotSpot
Clarence J M Tauro
Senior Curriculum Developer, Oracle ST Java Curriculum
3
<Insert Picture Here>
Session Agenda
• About the Speaker
• Different aspects of Performance
• Memory leaks and profiling
• Demo
4
About the Speaker
• Clarence J M Tauro – [email protected]
• 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
5
Different Aspects of Performance
Performance Aspects
Memory footprint
Scalability
Responsiveness
Throughput
In this talk we will look at memory profiling
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
7
Garbage Collection – An Overview
8
Garbage Collection – An Overview
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.
10
DEMO – A Servlet with a JavaScript Error
11
DEMO – Main Class
12
DEMO – NetBeans Profiler Configuration
I am interested in Garbage collection
statistics too
Choosing this option has a lot of additional
overhead
13
DEMO – Telemetry Overview
14
DEMO – Live Profiling Results
15
DEMO – Snapshot of String Class
16
DEMO – Stack Trace
17
DEMO – Source of handleScriptException
18
DEMO – Find Usaged on _errorMessages
19
DEMO – Source of ____________JavaScript.clearErrorMessages()
20
DEMO – Find Usages on -------------------------------------------------------------JavaScript.clearErrorMessages()
So, who calls the JavaScriptEngineFactory.clearErrorMessages()??
21
So, who calls the HttpUnitOptions.clearScriptErrorMessages()??
DEMO – Find Usages on JavaScriptEngineFactory.clearErrorMessages(
)
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.
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
24
• Java Performance Tuning and Optimization Course from
Oracle University
• Java Performance - Charlie Hunt (Author), Binu John (Author) (Expected
August 2011)
Where to go?
25