Leak Chaser Helping Programmers Narrow Down Causes of













- Slides: 13
Leak. Chaser: Helping Programmers Narrow Down Causes of Memory Leaks Guoqing Xu, Michael D. Bond, Feng Qin, Atanas Rountev Ohio State University
Java Memory Leaks • Objects are reachable, but not used – Kept by unnecessary references • Existing memory leak detection techniques – Unaware of program semantics: track arbitrary objects – No focus: profiling the whole execution--- real causes buried in a sea of likely problems • Developer insight is necessary in leak detection—a three-tier approach to exploit such insight Tier L Manual Leak. Chaser Tier M Tier H Manual Leak. Chaser
Exploiting Developer Insight • Heap assertions – GC Assertions: A reachability-based assertion framework [Aftandilian-PLDI’ 09] – E. g. , assert. Owns(a, b) – Works only for objects that have low-level structural reachability relationships • Lifetime invariants exist in large-scale apps – Lifetimes for certain objects are strongly correlated Screen s = new Screen(…); Configuration c = new Configuration(); /*s and c should always be created together and eventually die together */ 3
Tier L: Low-Level Liveness Assertions • An assertion framework to specify lifetime relationships – assert. Dies. Before(c, s) // s: Screen, c: Configuration – assert. Dies. Before. Alloc(s, s) • Our framework vs GC Assertions – Can be used to assert objects that have high-level semantic relationships (instead of low-level structural relationships) 4
High-Level Events: Transactions • Frequently-executed code regions – Likely to contain memory leaks – Inspired by EJB transactions • Allow programmers to specify transactions Result. Set run. Query(String query){ Connection c = get. Connection(…); Statement s = c. create. Stmt(); Result. Set r = s. execute. Query(query); return r; } Heap 5 rrun. Query … … rrun. Query …
Transaction Specification Result. Set run. Query(String query){ transaction (query) { Connection c = get. Connection(…); Statement s = c. create. Stmt(); Result. Set r = s. execute. Query(query); } return r; } • Transaction – A user-specified spatial boundary – A transaction identifier object that is correlated with the livenss of this region: temporal boundary 6
Tier M: Checking Transaction Properties • Semantics Result. Set run. Query(String query){ transaction (query) { Connection c = get. Connection(…); share{ Statement s = c. create. Stmt(); global. Map. cache(s); } Result. Set r = s. execute. Query(query); } return r; } for each object o created in this transaction do assert. Dies. Before (o, query) • Share region 7 for each object o created in this transaction Programmers do not need to if o is not created in share understand implementation details do assert. Dies. Before to use low-level assertions (o, query)
Tier H: Inferring Transaction Properties Result. Set run. Query(String query){ transaction (query, INFER ) { Connection c = get. Connection(…); Statement s = c. create. Stmt(); global. Map. cache(s); Result. Set r = s. execute. Query(query); } return r; } Programmers let Leak. Chaser do most of the work 8 • Minimum requirement for user involvement – Specify a transaction – Tell Leak. Chaser it runs in the inference mode • Semantics for each o created in this transaction if assert. Dies. Before (o, query) = false start. Track. Staleness(o) if(o. staleness >= S) report. Leak();
Three-Tier Approach • Tier H, Tier M, and Tier L – Decreasing levels of abstraction – More knowledge required for diagnosis – Increased precision • Leak. Chaser: an iterative diagnosis process – Start Tier H with little knowledge – Gradually explore leaky behaviors to locate the root cause 9
Case Studies • Six case studies on real-world applications – Eclipse diff (bug #115789) – SPECJbb 2000: Leak. Chaser found a memory problem never reported before – Eclipse editor (bug #139465): quickly concluded that this was not a bug – Eclipse WTP (bug #155898): found the cause for this bug that was reported three years ago and is still open – My. SQL leak – Mckoi leak: first time found that a leaking thread is the root cause • The ability of diagnosing problems for a large system at its client 10
Implementation • Jikes RVM – Works for both baseline and optimizing compilers – Works for all non-generational tracing GCs • Overhead on Fast. Adaptive. Immix (average) – Infrastructure: 10% on time, less than 10% on space – Transactions: 2. 3 X slowdown for 1088377 transactions 11
Conclusions • A three-tier approach for semantics-aware leak detection • An implementation in Jikes RVM • The transaction constructs can be easily incorporated into the Java language to help memory problem diagnosis • Leak. Chaser is available for download – http: //jikesrvm. org/Research+Archive 12
Thank you 13













