diagnosing memory leaks in large java applications

Similar documents
Understanding Performance in Large-scale Framework-based Systems

FIOSys (How FIOSys Works)

ORACLE ENTERPRISE MANAGER 10g ORACLE DIAGNOSTICS PACK FOR NON-ORACLE MIDDLEWARE

Go with the Flow: Profiling Copies to Find Run-time Bloat

Software Analysis. Asymptotic Performance Analysis

Zing Vision. Answering your toughest production Java performance questions

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Java performance - not so scary after all

memory management Vaibhav Bajpai

ACM Trivia Bowl. Thursday April 3 rd (two days from now) 7pm OLS 001 Snacks and drinks provided All are welcome! I will be there.

Virtual Memory #3 Oct. 10, 2018

An Indexing Scheme for a Scalable RDF Triple Store

Exploiting the Behavior of Generational Garbage Collector

From Java Code to Java Heap Understanding the Memory Usage of Your Application

Thin Locks: Featherweight Synchronization for Java

Midterm Exam Solutions Amy Murphy 28 February 2001

TUTORIAL: WHITE PAPER. VERITAS Indepth for the J2EE Platform PERFORMANCE MANAGEMENT FOR J2EE APPLICATIONS

Linked Lists. What is a Linked List?

CS 240 Fall Mike Lam, Professor. Priority Queues and Heaps

Summer Final Exam Review Session August 5, 2009

CSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality. Linda Shapiro Winter 2015

CSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality. Lauren Milne Spring 2015

Segmentation. Multiple Segments. Lecture Notes Week 6

Staleness and Isolation in Prometheus 2.0. Brian Brazil Founder

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

Operating Systems Lecture 6: Memory Management II

Performance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime

Automatic Memory Management

The Processor Memory Hierarchy

J2EE Instrumentation for software aging root cause application component determination with AspectJ

Memory Management: The Details

Automatic Garbage Collection

Kodewerk. Java Performance Services. The War on Latency. Reducing Dead Time Kirk Pepperdine Principle Kodewerk Ltd.

The HALFWORD HEAP EMULATOR

Advanced Programming & C++ Language

Habanero Extreme Scale Software Research Project

Programming Language Implementation

현재이이미지를표시할수없습니다. Chapter 9: Virtual Memory

Lecture 15 Advanced Garbage Collection

One-Slide Summary. Lecture Outine. Automatic Memory Management #1. Why Automatic Memory Management? Garbage Collection.

Lecture 13: Garbage Collection

June IBM Power Academy. IBM PowerVM memory virtualization. Luca Comparini STG Lab Services Europe IBM FR. June,13 th Dubai

IP subnetting made easy

Run-Time Environments/Garbage Collection

We've tried to include the common errors and grading standard for every question.

Nooks. Robert Grimm New York University

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides

CMSC 330: Organization of Programming Languages

6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare.

Erlang in the battlefield. Łukasz Kubica Telco BSS R&D Department Cracow Erlang Factory Lite, 2013

Exception Safety. CS 311 Data Structures and Algorithms Lecture Slides Wednesday, October 28, Glenn G. Chappell. continued

Dynamic Storage Allocation

Summary: Open Questions:

Practical Lessons in Memory Analysis

Data structures. Priority queues, binary heaps. Dr. Alex Gerdes DIT961 - VT 2018

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Basic Steps and Features Walk-through

Lecture Notes: Unleashing MAYHEM on Binary Code

Introduction. Chapter 1:

Synchronization. CS61, Lecture 18. Prof. Stephen Chong November 3, 2011

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

Intel Threading Tools

Heap Management. Heap Allocation

Bugs in Deployed Software

Which Configuration Option Should I Change?

Economies of Scale in Hacking Dave Aitel Immunity

Advanced Java Concepts Unit 2: Linked Lists.

Performance Case Study

Hi everyone. Starting this week I'm going to make a couple tweaks to how section is run. The first thing is that I'm going to go over all the slides

New Algorithms for Attack Planning

Memory Allocation, Page Replacement and Working Sets

Heapy a memory profiler and debugger for Python

CMSC 330: Organization of Programming Languages

CSE 544 Principles of Database Management Systems

SAP Memory Analyzer: Multi-Gigabyte Java Heap Dumps Are Nothing to Fear Now

Real-Time Garbage Collection Panel JTRES 2007

Diagnostics in Testing and Performance Engineering

Testing Objectives. Successful testing: discovers previously unknown errors

1 Performance Optimization in Java/J2EE

Distributed Algorithms 6.046J, Spring, 2015 Part 2. Nancy Lynch

Dell PowerEdge R730xd Servers with Samsung SM1715 NVMe Drives Powers the Aerospike Fraud Prevention Benchmark

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

To Kill a Monolith: Slaying the Demons of a Monolith with Node.js Microservices on CloudFoundry. Tony Erwin,

Chapter 8. Operating System Support. Yonsei University

CS61C : Machine Structures

Fast and Lock-Free Concurrent Priority Queues for Multi-Thread Systems

malloc(), calloc(), realloc(), and free()

Mozart System Limitations for Version (draft)

Week 12: Priority queues Heaps and heap operations

COMP 530: Operating Systems File Systems: Fundamentals

I J C S I E International Science Press

FS Consistency & Journaling

Types II. Hwansoo Han

VMem. By Stewart Lynch.

Java Concurrency in practice Chapter 9 GUI Applications

16 Sharing Main Memory Segmentation and Paging

Chapter 9: Virtual Memory

CS162 Operating Systems and Systems Programming Lecture 14. Caching (Finished), Demand Paging

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

Transcription:

diagnosing memory leaks in large java applications Nick Mitchell, Gary Sevitsky nickm@us.ibm.com, sevitsky@us.ibm.com IBM J Watson Research Center Hawthorne, New York, USA July 24, 2003

our two challenges big applications framework-heavy: J2EE web transaction processing object-noisy: myriad language-level memory managers high-volume: problem resolution occurs in (or near) production small tools automated: small budget for expertise and diagnosis time lightweight: tool must slow down production by <5%

knowing the common datatypes doesn't help much live instances java/lang/string 230025 com/ibm/servlet/util/hashtableentry 92825 java/util/hashtable$entry 59727 org/apache/xerces/dom/extimpl 15627 org/apache/xerces/dom/attrimpl 11278 org/apache/xalan/xpath/xml/stringostringable 11204...... org/apache/xerces/dom/documentimpl 52 (in addition allocation sites are expensive to know, and, by themselves, don't add too much)

factoring out objects via heap differencing is insufficient new live instances java/lang/string 9444 org/apache/xerces/dom/extimpl 6810 org/apache/xerces/dom/attrimpl 5290 java/util/hashtable$entry 3244 org/apache/xerces/dom/namednodemapimpl 2713 org/apache/xerces/dom/elementimpl 2123...... org/apache/xerces/dom/documentimpl 27

an atom of a leak (every leaking operation leaks lots of these objects) you're leaking Strings String

a bowl leaks (every leaking operation leaks one of these data structures) extimpl (an XML document) arrays ElementImpl AttrImpl DocumentImpl a whole leaking bowl of spaghetti NamedNodeMapImpl Vector AttrImpl String

group into data structures? # constituents com/ibm/servlet/dynamicclassloader 82882 com/ibm/servlet/dynamicclassloader 73537 com/.../xslransform 71628 com/.../propertiesfactory 66957 elements of Finalizer queue 39886 org/apache/xalan/xslt/emplatelist 28969 owned by native code 18829...... if we wait long enough, then the leaking data structure will float to the top; otherwise, noise effects dominate

anatomy of a leak diagnose memory problems by understanding how regions within the reference graph evolve over time you're leaking Strings there is a region of the XSL rendering engine that is leaking XML docs leaking into a Vector

categories of region evolution XML documents

categories of region evolution XML documents

categories of region evolution growing without bound (a leak)

categories of region evolution constituency doesn't change (a pool) constituency is in flux (hot cache) growing without bound (a leak) transient (transaction-local) shrinking (cold cache)

summary of approach 1. reconstitute regions from reference graph use dominance, reachability, age, datatype 2. construct short-list of candidate leaking regions use mixture model to rank regions e.g. from 1M live objects, identify handful of highly-ranked regions 3. online probing validates, categorizes candidates introduce region change detectors, short traversals of a reference graph to detect three kinds of region evolution achieves perturbation of <2%

what defines a region? XSLransform XSLEngineImpl Vector [Object

what defines a region? oops, a leak! DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object

what defines a region? DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object oops, a leak! DocumentImpl ElementImpl

what defines a region? DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object DocumentImpl ElementImpl the set of objects that is historically on the fringe between old and new objects

what distinguishes regions? two regions, distinguished by datatype on the historic fringe DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object DocumentImpl ElementImpl Keytable

what distinguishes regions? two regions, distinguished by owning container DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object DocumentImpl ElementImpl Stack [Object DocumentImpl

what distinguishes regions? two regions, distinguished by root data structure DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object DocumentImpl ElementImpl emplatecache Hashtable [Hashtable$Entry DocumentImpl

region keys L: leak root DocumentImpl ElementImpl XSLransform XSLEngineImpl Vector [Object O: owner proxy DocumentImpl ElementImpl C: change proxy for each object o, associate region key (L,O,C) set of unique keys is initial set of regions

finding L, good leak roots Define leak root metric, LRM=B M G, such that each leaking region has one o with LRM(o)>0, and few o's have LRM(o)>. B: eight binary rules to rule out impossible (be Sherleak Holmes!) narrow from a million to a hundred M: mixture model to rank the remaining narrow from a hundred to tens G: global fixpoint to ensure uniqueness narrow from tens to a handful of highly-ranked leak roots

C. ibid for objects not at the head of a single-entry region B: ruling out the impossible (using structural information) fraction of objects remaining # objects -A -A-B -A-B-C -A-B-C-D phone company 267,956 0.67 0.59 0.09 0.06 IDE 350,136 0.61 0.55 0.09 0.07 brokerage1 838,912 0.65 0.62 0.07 0.03 brokerage2 1,015,112 0.71 0.70 0.02 0.01 credit bureau 1,320,953 0.60 0.56 0.11 0.08 D D A. objects pointing to nothing aren't very interesting B. arrays themselves don't leak (but their dominating containers might) C D B A A D. objects which don't uniquely own anything also aren't interesting

B: ruling out the impossible (using temporal information) # objects remaining # objects -structural -E -E-F -E-F-G all told phone company 267,956 16,346 73 73 72 29 IDE 350,136 25,653 99 99 29 10 brokerage1 838,912 26,291 97 82 81 67 brokerage2 1,015,112 12,020 102 102 64 17 credit bureau 1,320,953 160,900 579 519 518 242 E. ignore structures that contain only old or only new objects (e.g. an already-primed pool) F. structures that contain only new arrays are borinng (theres nothing new in those arrays) G. ignore structures with no overlap in datatypes over time H. structures that contain no objects on the fringe are safe to ignore

M: the mixture model no single property is entirely indicative instead, use gated mixure of them all instances newer on-stack on-fringe type overlap EventNotifier 377,276 34% 0 44 33% hreaddiscriminator 274,433 2% 455 52 13% FormProperties 270 97% 50 3 100% XslemplateCache 32 90% 0 1 40% VerifySignonScenario 18 11% 1 1 50% this application had two leaks e.g. gating function

LRM=B M G, on brokerage2 (before applying the bug fixes) # constituents size rank LRM(o) com/.../eventnotifier 377276 1 0.895 com/.../formproperties 270 157 0.658 com/.../xslemplatecollection 32 841 0.463 com/.../verifysignonscenario 18 1050 0.420 of the highest-ranked candidate roots, the top two indeed leak (from 1,015,112 live objects)

LRM=B M G, on brokerage2 (after applying the bug fixes) # constituents size rank LRM(o) com/websphere/alarmhread 399 130 0.322 com/.../contextmodel 837 86 0.266 com/websphere/poolmanager 391 134 0.260 com/websphere/poolepm 385 137 0.254 after fixing the leak, there are no stand-out candidates (from 779,540 live objects)

detecting evolution cheaply a region evolves when elements are added to removed from relinked within track evolution with region change detectors

detecting evolution cheaply a region evolves when elements are added to removed from relinked within track evolution with region change detectors a detector is a tuple (R,H,,B,P,M) R: region to detect changes in H,: the head and tail of a short, bounded-size traversal B: a sample bias P: a match precondition M: a mutator, updates the set of existing detectors

XML documents a region evolves

XML documents a region evolves

a region evolves growing without bound (a leak)

a region evolves along the historic fringe thus, the traversals are the short path which just spans the fringe H

a region evolves along the historic fringe H H H H thus, the traversals are the short path which just spans the fringe H

preconditions instanceof DocumentImpl for additions, the precondition P is the datatype of the change proxy

a precondition is matched

once a detector fires, we mutate the set of detectors M: for additions, we remove the firing addition detector increase B of detectors with same R add removal detector add new addition detectors

leakbot and its loops snapshot the heap sleep recontruct regions dotimes(n) { d=next detector if(d.b > rand()) { traverse from d.h to d. if(d.p(d.)) { d.m() } } sleep } rank regions generate region change detectors

diagnosing memory leaks in large java applications Nick Mitchell, Gary Sevitsky nickm@us.ibm.com, sevitsky@us.ibm.com IBM J Watson Research Center Hawthorne, New York, USA July 24, 2003

checking data structure properties at runtime, cheaply and automatically Nick Mitchell, Gary Sevitsky nickm@us.ibm.com, sevitsky@us.ibm.com IBM J Watson Research Center Hawthorne, New York, USA July 24, 2003

leakbot in action just after initial analysis over time... about one minute later a non-leaking region and another few minutes... is downgraded

Strategies for Dissecting histogram by datatype Leaks (and some problems with each) Strings are in every data structure histogram by allocation site Strings are allocated everywhere expensive (c.f. HPROF's 5-10x slowdown) visualize reference graph an application doesn't just leak objects, it leaks entire (and entirely ugly) data structures c.f. Jinsight, JProbe, Purify

Summary of the LeakBot echnique structure live objects into Co-evolving Regions portions of data structures which change in similar ways rank regions according to likelihood of problem only present to user those regions likely to leak, the suspects e.g. of Schwab's 1M live objects, leakbot identifies three suspects offline mode track evolution of regions as program runs treat structuring and ranking as initial estimates e.g. we might have caught a pool being populated it'll eventually plateau from them, derive a scheme for very lightweight probing verify whether initial estimates correct, and update ranking online mode

anatomy of a leak? String