Abstract
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.
Supplemental Material
Available for Download
The zip file contains Appendix A and Appendix B to the paper "BLeak: Automatically Debugging Memory Leaks in Web Applications" (PLDI 2018). Appendix A lists all of the memory leaks that we found and fixed using BLeak, while Appendix B lists the code for all of the loops used in the evaluation.
- Edward Aftandilian and Samuel Z. Guyer. 2009. GC Assertions: Using the Garbage Collector to Check Heap Properties. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation. 235–244. Google ScholarDigital Library
- Airbnb, Inc. 2017. Vacation Rentals, Homes, Experiences, & Places -Airbnb. http://airbnb.com/ . {Online; accessed 12-October-2017}.Google Scholar
- Bill Allombert, Avery Pennarun, Bill Allombert, and Petter Reinholdtsen. 2017. Debian Popularity Contest. https://popcon.debian.org/ . See entries for iceweasel and chromium-browser. {Online; accessed 4-November-2017}.Google Scholar
- Babel. 2017. Babel - The compiler for writing next generation JavaScript. https://babeljs.io/ . {Online; accessed 15-October-2017}.Google Scholar
- Dmitry Baranovskiy. 2017. DmitryBaranovskiy/raphael: JavaScript Vector Library. https://github.com/DmitryBaranovskiy/raphael . {Online; accessed 6-November-2017}.Google Scholar
- Kayce Basques. 2017. Fix Memory Problems. https://developers.google. com/web/tools/chrome- devtools/memory- problems/ . {Online; accessed 2-November-2017}.Google Scholar
- Jason Bedard. 2017. Deferred: fix memory leak of promise callbacks. https://github.com/jquery/jquery/pull/3657 . {Online; accessed 8-November-2017}.Google Scholar
- Michael D. Bond and Kathryn S. McKinley. 2006. Bell: bit-encoding online memory leak detection. In Proceedings of the 12th International Conference on Architectural Support for Programming Languages and Operating Systems. 61–72. Google ScholarDigital Library
- James A. Clause and Alessandro Orso. 2010. LEAKPOINT: pinpointing the causes of memory leaks. In Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering - Volume 1. 515–524. Google ScholarDigital Library
- Jeff Collins. 2017. jeff-collins/ment.io: Mentions and Macros for Angular. https://github.com/jeff- collins/ment.io . {Online; accessed 6-November-2017}.Google Scholar
- Aldo Cortesi, Maximilian Hils, Thomas Kriechbaumer, and contributors. 2010–. mitmproxy: A free and open source interactive HTTPS proxy. https://mitmproxy.org/ {Online; accessed 15-October-2017}.Google Scholar
- Criteo. 2017. Criteo OneTag Explained. https://support.criteo.com/hc/ en- us/articles/202726972- Criteo- OneTag- explained . {Online; accessed 6-November-2017}.Google Scholar
- Steve Dent. 2017. Firefox ‘performance’ tab will curb its RAM hunger. https://www.engadget.com/2017/04/13/ firefox- performance- tab- will- curb- its- ram- hunger/ . {Online; accessed 4-November-2017}.Google Scholar
- Filament Group, Inc. 2017. filamentgroup/loadCSS: A function for loading CSS asynchronously. https://github.com/filamentgroup/loadCSS . {Online; accessed 6-November-2017}.Google Scholar
- Firefox Developer Tools Team. 2017. debugger.html: The Firefox debugger that works anywhere. http://firefox- dev.tools/debugger.html/ . {Online; accessed 12-October-2017}.Google Scholar
- Google. 2011. Bug: Destroying Google Map Instance Never Frees Memory. https://issuetracker.google.com/issues/35821412 . {Online; accessed 2-November-2017}.Google Scholar
- Google. 2017. Adding analytics.js to Your Site. https://developers. google.com/analytics/devguides/collection/analyticsjs/ . {Online; accessed 6-November-2017}.Google Scholar
- Google. 2017. angular/angular.js: AngularJS - HTML enhanced for web apps! https://github.com/angular/angular.js . {Online; accessed 6-November-2017}.Google Scholar
- Google. 2017. Chrome DevTools Protocol Viewer. https:// chromedevtools.github.io/devtools- protocol/ . {Online; accessed 7-November-2017}.Google Scholar
- Google. 2017. Google Maps JavaScript API. https://developers.google. com/maps/documentation/javascript/ . {Online; accessed 6-November2017}.Google Scholar
- Google. 2017. Speed up Google Chrome. https://support.google.com/ chrome/answer/1385029 . {Online; accessed 4-November-2017}.Google Scholar
- Google. 2017. Tag Management Solutions for Web and Mobile. https://www.google.com/analytics/tag- manager/ . {Online; accessed 6-November-2017}.Google Scholar
- Kentaro Hara. 2013. Oilpan: GC for Blink. https://docs.google.com/presentation/d/ 1YtfurcyKFS0hxPOnC3U6JJroM8aRP49Yf0QWznZ9jrk . {Online; accessed 4-November-2017}.Google Scholar
- Kentaro Hara. 2017. State of Blink’s Speed. https://docs.google.com/presentation/d/ 1Az- F3CamBq6hZ5QqQt- ynQEMWEhHY1VTvlRwL7b_6TU . See slide 46. {Online; accessed 2-November-2017}.Google Scholar
- Matthias Hauswirth and Trishul M. Chilimbi. 2004. Low-overhead memory leak detection using adaptive statistical profiling. In Proceedings of the 11th International Conference on Architectural Support for Programming Languages and Operating Systems. 156–164. Google ScholarDigital Library
- Alan Henry. 2011. How Do I Stop My Browser from Slowing to a Crawl? https://lifehacker.com/5833074/ how- do- i- stop- my- browser- from- slowing- to- a- crawl . {Online; accessed 4-November-2017}.Google Scholar
- Simon Holm Jensen, Manu Sridharan, Koushik Sen, and Satish Chandra. 2015. MemInsight: Platform-Independent Memory Debugging for JavaScript. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering. 345–356. Google ScholarDigital Library
- Maria Jump and Kathryn S. McKinley. 2007. Cork: dynamic memory leak detection for garbage-collected languages. In Proceedings of the 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 31–38. Google ScholarDigital Library
- Meggin Kearney. 2017. How to Record Heap Snapshots. https://developers.google.com/web/tools/chrome- devtools/ memory- problems/heap- snapshots . {Online; accessed 11-November2017}.Google Scholar
- Emre Kiciman and Benjamin Livshits. 2007. AjaxScope: A platform for remotely monitoring the client-side behavior of web 2.0 applications. In Proceedings of the 21st ACM Symposium on Operating Systems Principles. 17–30. Google ScholarDigital Library
- Loreena Lee and Robert Hundt. 2012. BloatBusters: Eliminating memory leaks in Gmail. https://docs.google.com/presentation/d/ 1wUVmf78gG- ra5aOxvTf YdiLkdGaR9OhXRnOlIcEmu2s . {Online; accessed 2-November-2017}.Google Scholar
- Joe Lencioni. 2017. Possible memory leak when used with the same URL multiple times. https://github.com/filamentgroup/loadCSS/ issues/236 . {Online; accessed 6-November-2017}.Google Scholar
- James Teng Kin Lo, Eric Wohlstadter, and Ali Mesbah. 2013. Imagen: runtime migration of browser sessions for JavaScript web applications. In 22nd International World Wide Web Conference. 815–826. http://dl. acm.org/citation.cfm?id=2488459 Google ScholarDigital Library
- Loomio Cooperative Limited. 2017. Loomio - Better decisions together. https://www.loomio.org/ . {Online; accessed 12-October-2017}.Google Scholar
- Mailpile Team. 2017. Mailpile Demo’s mailpile v1.0.0rc0. https://demo. mailpile.is/in/inbox/ . {Online; accessed 8-November-2017}.Google Scholar
- Mailpile Team. 2017. Mailpile: e-mail that protects your privacy. http: //mailpile.is/ . {Online; accessed 12-October-2017}.Google Scholar
- Materialize. 2017. Dogfalo/materialize: Materialize, a CSS Framework based on Material Design. https://github.com/Dogfalo/materialize . {Online; accessed 6-November-2017}.Google Scholar
- Kirk McElhearn. 2016. It’s time for Safari to go on a memory diet. https://www.macworld.com/article/3148256/browsers/ it- s- time- for- safari- to- go- on- a- memory- diet.html . {Online; accessed 4-November-2017}.Google Scholar
- Kirk McElhearn. 2017. Apple’s Safari Web Browser Now Uses Much Less Memory. https://www.kirkville.com/ apples- safari- web- browser- now- uses- much- less- memory/ . {Online; accessed 4-November-2017}.Google Scholar
- Microsoft. 2017. Microsoft Edge F12 DevTools - Memory. https://docs. microsoft.com/en- us/microsoft- edge/f12- devtools- guide/memory . {Online; accessed 4-November-2017}.Google Scholar
- Nick Mitchell and Gary Sevitsky. 2003. LeakBot: An Automated and Lightweight Tool for Diagnosing Memory Leaks in Large Java Applications. In Proceedings of ECOOP 2003 - Object-Oriented Programming. 351–377.Google ScholarCross Ref
- Mozilla. 2017. about:memory. https://developer.mozilla.org/en- US/ docs/Mozilla/Performance/about:memory . {Online; accessed 4-November-2017}.Google Scholar
- Mozilla. 2017. Firefox uses too much memory (RAM) -How to fix. https://support.mozilla.org/en- US/kb/ firefox- uses- too- much- memory- ram . {Online; accessed 4-November-2017}.Google Scholar
- Mozilla. 2017. Memory - Firefox Developer Tools. https://developer. mozilla.org/en- US/docs/Tools/Memory . {Online; accessed 11-November-2017}.Google Scholar
- Mozilla. 2017. SensorWeb. http://aws- sensorweb- static- site. s3- website- us- west- 2.amazonaws.com/ . {Online; accessed 2-November-2017}.Google Scholar
- Mozilla Development Network. 2017. Proxy - JavaScript. https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/ Global_Objects/Proxy . {Online; accessed 7-November-2017}.Google Scholar
- Nick Nguyen. 2017. The Best Firefox Ever. https://blog.mozilla.org/ blog/2017/06/13/faster- better- firefox/ . {Online; accessed 4-November2017}.Google Scholar
- Gene Novark, Emery D. Berger, and Benjamin G. Zorn. 2009. Efficiently and precisely locating memory leaks and bloat. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation. 397–407. Google ScholarDigital Library
- Joseph Pecoraro. 2016. Memory Debugging with Web Inspector. https: //webkit.org/blog/6425/memory- debugging- with- web- inspector/ . {Online; accessed 4-November-2017}.Google Scholar
- Jacques A. Pienaar and Robert Hundt. 2013. JSWhiz: Static analysis for JavaScript memory leaks. In Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization. 11:1– 11:11. Google ScholarDigital Library
- Piwik.org. 2017. #1 Free Web & Mobile Analytics Software. https: //piwik.org/ . {Online; accessed 12-October-2017}.Google Scholar
- Masoomeh Rudafshani and Paul A. S. Ward. 2017. LeakSpot: Detection and diagnosis of memory leaks in JavaScript applications. Software: Practice and Experience 47, 1 (2017), 97–123. Google ScholarDigital Library
- Greg Sterling. 2015. No, Apps Aren’t Winning. The Mobile Browser Is. http://marketingland.com/ morgan- stanley- no- apps- arent- winning- themobile- browser- is- 144303 . {Online; accessed 2-November-2017}.Google Scholar
- The jQuery Foundation. 2017. jquery/jquery: jQuery JavaScript Library. https://github.com/jquery/jquery/ . {Online; accessed 6-November2017}.Google Scholar
- John Vilk. 2017. {Browser Client} Minor memory leak: “.mail_source” event resubscriptions. https://github.com/mailpile/Mailpile/issues/ 1911 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. {Browser Client} Minor memory leak: Text nodes in notification area. https://github.com/mailpile/Mailpile/issues/1931 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Fix memory leak in Element.removeData(). https:// github.com/DmitryBaranovskiy/raphael/pull/1077 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Fix memory leaks in data table / jqplot. https://github. com/piwik/piwik/pull/11354 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Fix multiple memory leaks in UserCountryMap. https: //github.com/piwik/piwik/pull/11350 . {Online; accessed 8-November2017}.Google Scholar
- John Vilk. 2017. Fix UIControl memory leak. https://github.com/piwik/ piwik/pull/11362 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. JavaScript Memory Leak: #columnPreview click handlers. https://github.com/piwik/piwik/issues/12058 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. JavaScript Memory Leak: widgetContent $destroy handlers. https://github.com/piwik/piwik/issues/12059 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Memory Leak: gtm.js repeatedly appends conversion_async.js to head when pushing to dataLayer. https://goo.gl/ WFPt4M . {Online; accessed 6-November-2017}.Google Scholar
- John Vilk. 2017. Memory Leak in Preview Component. https://github. com/devtools- html/debugger.html/issues/3822 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Memory Leak: material_select never removes global click handlers. https://github.com/Dogfalo/materialize/issues/4266 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Minor frontend memory leaks due to unremoved LokiJS dynamic views. https://github.com/loomio/loomio/issues/4248 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Minor JavaScript Memory Leak: piwikApiService allRequests array. https://github.com/piwik/piwik/issues/12105 . {Online; accessed 8-November-2017}.Google Scholar
- John Vilk. 2017. Small Memory Leak and Correctness Bug in analytics.js. https://issuetracker.google.com/issues/66525724 . {Online; accessed 6-November-2017}.Google Scholar
- John Vilk. 2017. Small memory leak: Callbacks added to window._xdc_ are never cleared. https://issuetracker.google.com/issues/66529186 . {Online; accessed 6-November-2017}.Google Scholar
- John Vilk. 2017. Small Memory Leak in $rootScope.$on. https://github. com/angular/angular.js/issues/16135 . {Online; accessed 8-November2017}.Google Scholar
- John Vilk and Emery D. Berger. 2018. BLeak repository. https://github. com/plasma- umass/bleak . {Online; accessed 20-March-2018}.Google Scholar
- Brent Wheeldon. 2017. Unbind events to prevent memory leaks. https://github.com/jeff- collins/ment.io/pull/138 . {Online; accessed 8-November-2017}.Google Scholar
- Guoqing (Harry) Xu, Michael D. Bond, Feng Qin, and Atanas Rountev. 2011. LeakChaser: Helping programmers narrow down causes of memory leaks. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation. 270–282. Google ScholarDigital Library
- Guoqing (Harry) Xu and Atanas Rountev. 2013. Precise memory leak detection for Java software using container profiling. ACM Transactions on Software Engineering and Methodology 22, 3 (2013), 17:1–17:28. Google ScholarDigital Library
- Limin Zhu. 2017. Improved JavaScript performance, WebAssembly, and Shared Memory in Microsoft Edge. https://blogs.windows.com/msedgedev/2017/04/20/ improved- javascript- performance- webassembly- shared- memory . {Online; accessed 4-November-2017}.Google Scholar
Index Terms
- BLeak: automatically debugging memory leaks in web applications
Recommendations
BLeak: automatically debugging memory leaks in web applications
Memory leaks in web applications are pervasive and difficult to debug. Leaks degrade responsiveness by increasing garbage collection costs and can even lead to browser tab crashes. Previous leak detection approaches designed for conventional ...
BLeak: automatically debugging memory leaks in web applications
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationDespite 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 ...
Migration of Web Applications with Seamless Execution
VEE '15Web applications (apps) are programmed using HTML5, CSS, and JavaScript, and are distributed in the source code format. Web apps can be executed on any devices where a web browser is installed, allowing one-source, multi-platform environment. We can ...
Comments