skip to main content
research-article
Public Access
Artifacts Available
Artifacts Evaluated & Functional

BLeak: automatically debugging memory leaks in web applications

Published:11 June 2018Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

p15-vilk.webm

webm

119.3 MB

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. Airbnb, Inc. 2017. Vacation Rentals, Homes, Experiences, & Places -Airbnb. http://airbnb.com/ . {Online; accessed 12-October-2017}.Google ScholarGoogle Scholar
  3. 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 ScholarGoogle Scholar
  4. Babel. 2017. Babel - The compiler for writing next generation JavaScript. https://babeljs.io/ . {Online; accessed 15-October-2017}.Google ScholarGoogle Scholar
  5. Dmitry Baranovskiy. 2017. DmitryBaranovskiy/raphael: JavaScript Vector Library. https://github.com/DmitryBaranovskiy/raphael . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  6. Kayce Basques. 2017. Fix Memory Problems. https://developers.google. com/web/tools/chrome- devtools/memory- problems/ . {Online; accessed 2-November-2017}.Google ScholarGoogle Scholar
  7. Jason Bedard. 2017. Deferred: fix memory leak of promise callbacks. https://github.com/jquery/jquery/pull/3657 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. Criteo. 2017. Criteo OneTag Explained. https://support.criteo.com/hc/ en- us/articles/202726972- Criteo- OneTag- explained . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  13. 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 ScholarGoogle Scholar
  14. Filament Group, Inc. 2017. filamentgroup/loadCSS: A function for loading CSS asynchronously. https://github.com/filamentgroup/loadCSS . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  15. 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 ScholarGoogle Scholar
  16. Google. 2011. Bug: Destroying Google Map Instance Never Frees Memory. https://issuetracker.google.com/issues/35821412 . {Online; accessed 2-November-2017}.Google ScholarGoogle Scholar
  17. Google. 2017. Adding analytics.js to Your Site. https://developers. google.com/analytics/devguides/collection/analyticsjs/ . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  18. Google. 2017. angular/angular.js: AngularJS - HTML enhanced for web apps! https://github.com/angular/angular.js . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  19. Google. 2017. Chrome DevTools Protocol Viewer. https:// chromedevtools.github.io/devtools- protocol/ . {Online; accessed 7-November-2017}.Google ScholarGoogle Scholar
  20. Google. 2017. Google Maps JavaScript API. https://developers.google. com/maps/documentation/javascript/ . {Online; accessed 6-November2017}.Google ScholarGoogle Scholar
  21. Google. 2017. Speed up Google Chrome. https://support.google.com/ chrome/answer/1385029 . {Online; accessed 4-November-2017}.Google ScholarGoogle Scholar
  22. Google. 2017. Tag Management Solutions for Web and Mobile. https://www.google.com/analytics/tag- manager/ . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  23. Kentaro Hara. 2013. Oilpan: GC for Blink. https://docs.google.com/presentation/d/ 1YtfurcyKFS0hxPOnC3U6JJroM8aRP49Yf0QWznZ9jrk . {Online; accessed 4-November-2017}.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle Scholar
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle Scholar
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle Scholar
  32. 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 ScholarGoogle Scholar
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. Loomio Cooperative Limited. 2017. Loomio - Better decisions together. https://www.loomio.org/ . {Online; accessed 12-October-2017}.Google ScholarGoogle Scholar
  35. Mailpile Team. 2017. Mailpile Demo’s mailpile v1.0.0rc0. https://demo. mailpile.is/in/inbox/ . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  36. Mailpile Team. 2017. Mailpile: e-mail that protects your privacy. http: //mailpile.is/ . {Online; accessed 12-October-2017}.Google ScholarGoogle Scholar
  37. Materialize. 2017. Dogfalo/materialize: Materialize, a CSS Framework based on Material Design. https://github.com/Dogfalo/materialize . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  38. 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 ScholarGoogle Scholar
  39. 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 ScholarGoogle Scholar
  40. 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 ScholarGoogle Scholar
  41. 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 ScholarGoogle ScholarCross RefCross Ref
  42. Mozilla. 2017. about:memory. https://developer.mozilla.org/en- US/ docs/Mozilla/Performance/about:memory . {Online; accessed 4-November-2017}.Google ScholarGoogle Scholar
  43. 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 ScholarGoogle Scholar
  44. Mozilla. 2017. Memory - Firefox Developer Tools. https://developer. mozilla.org/en- US/docs/Tools/Memory . {Online; accessed 11-November-2017}.Google ScholarGoogle Scholar
  45. Mozilla. 2017. SensorWeb. http://aws- sensorweb- static- site. s3- website- us- west- 2.amazonaws.com/ . {Online; accessed 2-November-2017}.Google ScholarGoogle Scholar
  46. 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 ScholarGoogle Scholar
  47. Nick Nguyen. 2017. The Best Firefox Ever. https://blog.mozilla.org/ blog/2017/06/13/faster- better- firefox/ . {Online; accessed 4-November2017}.Google ScholarGoogle Scholar
  48. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  49. Joseph Pecoraro. 2016. Memory Debugging with Web Inspector. https: //webkit.org/blog/6425/memory- debugging- with- web- inspector/ . {Online; accessed 4-November-2017}.Google ScholarGoogle Scholar
  50. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  51. Piwik.org. 2017. #1 Free Web & Mobile Analytics Software. https: //piwik.org/ . {Online; accessed 12-October-2017}.Google ScholarGoogle Scholar
  52. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  53. 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 ScholarGoogle Scholar
  54. The jQuery Foundation. 2017. jquery/jquery: jQuery JavaScript Library. https://github.com/jquery/jquery/ . {Online; accessed 6-November2017}.Google ScholarGoogle Scholar
  55. 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 ScholarGoogle Scholar
  56. 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 ScholarGoogle Scholar
  57. John Vilk. 2017. Fix memory leak in Element.removeData(). https:// github.com/DmitryBaranovskiy/raphael/pull/1077 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  58. John Vilk. 2017. Fix memory leaks in data table / jqplot. https://github. com/piwik/piwik/pull/11354 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  59. John Vilk. 2017. Fix multiple memory leaks in UserCountryMap. https: //github.com/piwik/piwik/pull/11350 . {Online; accessed 8-November2017}.Google ScholarGoogle Scholar
  60. John Vilk. 2017. Fix UIControl memory leak. https://github.com/piwik/ piwik/pull/11362 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  61. John Vilk. 2017. JavaScript Memory Leak: #columnPreview click handlers. https://github.com/piwik/piwik/issues/12058 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  62. John Vilk. 2017. JavaScript Memory Leak: widgetContent $destroy handlers. https://github.com/piwik/piwik/issues/12059 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  63. 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 ScholarGoogle Scholar
  64. John Vilk. 2017. Memory Leak in Preview Component. https://github. com/devtools- html/debugger.html/issues/3822 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  65. 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 ScholarGoogle Scholar
  66. 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 ScholarGoogle Scholar
  67. John Vilk. 2017. Minor JavaScript Memory Leak: piwikApiService allRequests array. https://github.com/piwik/piwik/issues/12105 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  68. John Vilk. 2017. Small Memory Leak and Correctness Bug in analytics.js. https://issuetracker.google.com/issues/66525724 . {Online; accessed 6-November-2017}.Google ScholarGoogle Scholar
  69. 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 ScholarGoogle Scholar
  70. John Vilk. 2017. Small Memory Leak in $rootScope.$on. https://github. com/angular/angular.js/issues/16135 . {Online; accessed 8-November2017}.Google ScholarGoogle Scholar
  71. John Vilk and Emery D. Berger. 2018. BLeak repository. https://github. com/plasma- umass/bleak . {Online; accessed 20-March-2018}.Google ScholarGoogle Scholar
  72. Brent Wheeldon. 2017. Unbind events to prevent memory leaks. https://github.com/jeff- collins/ment.io/pull/138 . {Online; accessed 8-November-2017}.Google ScholarGoogle Scholar
  73. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  74. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  75. 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 ScholarGoogle Scholar

Index Terms

  1. BLeak: automatically debugging memory leaks in web applications

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 53, Issue 4
      PLDI '18
      April 2018
      834 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/3296979
      Issue’s Table of Contents
      • cover image ACM Conferences
        PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation
        June 2018
        825 pages
        ISBN:9781450356985
        DOI:10.1145/3192366

      Copyright © 2018 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 11 June 2018

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader