BLeak: automatically debugging memory leaks in web applications

BLeak: automatically debugging memory leaks in web applications
复制标题

DOI:
10.1145/3192366.3192376
复制
发表时间:
2018-06
期刊:
Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation
影响因子:
--
通讯作者:
J. Vilk;E. Berger
J. Vilk;E. Berger
中科院分区:
其他
文献类型:
--
作者:
J. Vilk;E. Berger

文献摘要

被引文献

相似文献

尽管 JavaScript 等托管语言中存在垃圾收集,但内存泄漏仍然是一个严重的问题。在 Web 应用程序的上下文中,这些泄漏尤其普遍且难以调试。 Web 应用程序内存泄漏可能有多种形式,包括未能处理不需要的事件侦听器、重复注入 iframe 和 CSS 文件以及未能调用第三方库中的清理例程。泄漏会增加 GC 频率和开销,从而降低响应能力,甚至可能会耗尽可用内存,从而导致浏览器选项卡崩溃。由于以前为传统 C、C++ 或 Java 应用程序设计的泄漏检测方法在浏览器环境中无效,因此当前跟踪泄漏需要 Web 开发人员进行大量的手动工作。本文介绍了 BLeak(浏览器泄漏调试器),这是第一个用于自动调试 Web 应用程序中内存泄漏的系统。 BLeak 的算法利用了这样的观察结果:在现代 Web 应用程序中,用户经常反复返回到相同(近似)的视觉状态(例如 Gmail 中的收件箱视图)。往返之间的持续增长是内存泄漏的有力指标。为了使用 BLeak,开发人员需要编写一个简短的脚本(在我们的基准测试中为 17-73 LOC)来驱动 Web 应用程序往返到相同的视觉状态。然后,BLeak 自动生成发现的泄漏列表及其根本原因,并按投资回报率排名。在 BLeak 的指导下,我们识别并修复了流行库和应用程序中的 50 多个内存泄漏,包括 Airbnb、AngularJS、Google Analytics、Google Maps SDK 和 jQuery。 BLeak的中位精度为100%;修复它识别出的泄漏可平均减少 94% 的堆增长,每次往返节省 0.5 MB 到 8 MB。我们相信 BLeak 的方法不仅适用于 Web 应用程序,还广泛适用于桌面和移动平台上的 GUI 应用程序。
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.