BLeak: automatically debugging memory leaks in web applications

Despite the presence of garbage collection in managed languages like JavaScript, memory leaks remain a serious problem. In the context of web applications, these leaks are especially pervasive and difficult to debug. Web application memory leaks can take many forms, including failing to dispose of unneeded event listeners, repeatedly injecting iframes and CSS files, and failing to call cleanup routines in third-party libraries. Leaks degrade responsiveness by increasing GC frequency and overhead, and can even lead to browser tab crashes by exhausting available memory. Because previous leak detection approaches designed for conventional C, C++ or Java applications are ineffective in the browser environment, tracking down leaks currently requires intensive manual effort by web developers. This paper introduces BLeak (Browser Leak debugger), the first system for automatically debugging memory leaks in web applications. BLeak's algorithms leverage the observation that in modern web applications, users often repeatedly return to the same (approximate) visual state (e.g., the inbox view in Gmail). Sustained growth between round trips is a strong indicator of a memory leak. To use BLeak, a developer writes a short script (17-73 LOC on our benchmarks) to drive a web application in round trips to the same visual state. BLeak then automatically generates a list of leaks found along with their root causes, ranked by return on investment. Guided by BLeak, we identify and fix over 50 memory leaks in popular libraries and apps including Airbnb, AngularJS, Google Analytics, Google Maps SDK, and jQuery. BLeak's median precision is 100%; fixing the leaks it identifies reduces heap growth by an average of 94%, saving from 0.5 MB to 8 MB per round trip. We believe BLeak's approach to be broadly applicable beyond web applications, including to GUI applications on desktop and mobile platforms.

[1]  John Vilk,et al.  BLeak: automatically debugging memory leaks in web applications , 2018, PLDI.

[2]  Paul A. S. Ward,et al.  LeakSpot: detection and diagnosis of memory leaks in JavaScript applications , 2017, Softw. Pract. Exp..

[3]  Matthias Hauswirth,et al.  Low-overhead memory leak detection using adaptive statistical profiling , 2004, ASPLOS XI.

[4]  Manu Sridharan,et al.  MemInsight: platform-independent memory debugging for JavaScript , 2015, ESEC/SIGSOFT FSE.

[5]  Alessandro Orso,et al.  LEAKPOINT: pinpointing the causes of memory leaks , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[6]  Kathryn S. McKinley,et al.  Cork: dynamic memory leak detection for garbage-collected languages , 2007, POPL '07.

[7]  HauswirthMatthias,et al.  Low-overhead memory leak detection using adaptive statistical profiling , 2004 .

[8]  Samuel Z. Guyer,et al.  GC assertions: using the garbage collector to check heap properties , 2008, MSPC '08.

[9]  Michael D. Bond,et al.  Bell: bit-encoding online memory leak detection , 2006, ASPLOS XII.

[10]  Nick Mitchell,et al.  LeakBot: An Automated and Lightweight Tool for Diagnosing Memory Leaks in Large Java Applications , 2003, ECOOP.

[11]  Atanas Rountev,et al.  Precise memory leak detection for java software using container profiling , 2013, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[12]  Robert Hundt,et al.  Static Analysis for JavaScript Memory Leaks , 2013 .

[13]  Robert Hundt,et al.  JSWhiz: Static analysis for JavaScript memory leaks , 2013, Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

[14]  Benjamin Livshits,et al.  AjaxScope: a platform for remotely monitoring the client-side behavior of web 2.0 applications , 2007, TWEB.

[15]  D BergerEmery,et al.  BLeak: automatically debugging memory leaks in web applications , 2018 .

[16]  Michael D. Bond,et al.  LeakChaser: helping programmers narrow down causes of memory leaks , 2011, PLDI '11.

[17]  Eric Wohlstadter,et al.  Imagen: runtime migration of browser sessions for javascript web applications , 2013, WWW.

[18]  Emery D. Berger,et al.  Efficiently and precisely locating memory leaks and bloat , 2009, PLDI '09.