Abstract
Garbage-collected language runtimes carefully tune heap limits to reduce garbage collection time and memory usage. However, there's a trade-off: a lower heap limit reduces memory use but increases garbage collection time. Classic methods for setting heap limits include manually tuned heap limits and multiple-of-live-size rules of thumb, but it is not clear when one rule is better than another or how to compare them.
We address this problem with a new framework where heap limits are set for multiple heaps at once. Our key insight is that every heap limit rule induces a particular allocation of memory across multiple processes, and this allocation can be sub-optimal. We use our framework to derive an optimal "square-root" heap limit rule, which minimizes total memory usage for any amount of total garbage collection time. Paradoxically, the square-root heap limit rule achieves this coordination without communication: it allocates memory optimally across multiple heaps without requiring any communication between those heaps.
To demonstrate that this heap limit rule is effective, we prototype it for V8, the JavaScript runtime used in Google Chrome, Microsoft Edge, and other browsers, as well as in server-side frameworks like node.js and Deno. On real-world web pages, our prototype achieves reductions of approximately 16.0% of memory usage while keeping garbage collection time constant. On memory-intensive benchmarks, reductions of up to 30.0% of garbage collection time are possible with no change in total memory usage.
- Ayush Agarwal, Sioli O’Connell, Jason Kim, Shaked Yehezkel, Daniel Genkin, Eyal Ronen, and Yuval Yarom. 2022. Spook.js: Attacking Chrome Strict Site Isolation via Speculative Execution. In 43rd IEEE Symposium on Security and Privacy (S&P’22). 93–101. https://doi.org/10.1109/SP46214.2022.9833711
Google Scholar
Cross Ref
- Martin Aigner, Thomas Hütter, Christoph M Kirsch, Alexander Miller, Hannes Payer, and Mario Preishuber. 2014. ACDC-JS: explorative benchmarking of javascript memory management. ACM SIGPLAN Notices, 50, 2 (2014), 67–78. https://doi.org/10.1145/2661088.2661089
Google Scholar
Digital Library
- Mythri Alle, Dan Elphick, and Ross McIlroy. 2019. A Lighter V8. https://v8.dev/blog/v8-lite
Google Scholar
- Raphael Alonso and Andrew W. Appel. 1990. An Advisor for Flexible Working Sets. SIGMETRICS ’90. Association for Computing Machinery, New York, NY, USA. 153–162. isbn:0897913590 https://doi.org/10.1145/98457.98753
Google Scholar
Digital Library
- Edd Barrett, Carl Friedrich Bolz-Tereick, Rebecca Killick, Vincent Knight, Sarah Mount, and Laurence Tratt. 2017. Virtual Machine Warmup Blows Hot and Cold. In OOPSLA. ACM, 27 pages. https://doi.org/10.1145/3133876
Google Scholar
Digital Library
- Tim Brecht, Eshrat Arjomandi, Chang Li, and Hang Pham. 2006. Controlling Garbage Collection and Heap Growth to Reduce the Execution Time of Java Applications. ACM Trans. Program. Lang. Syst., 28, 5 (2006), sep, 908–941. issn:0164-0925 https://doi.org/10.1145/1152649.1152652
Google Scholar
Digital Library
- Preston Briggs, Keith D. Cooper, and Linda Torczon. 1992. Rematerialization. SIGPLAN Not., 27, 7 (1992), jul, 311–321. issn:0362-1340 https://doi.org/10.1145/143103.143143
Google Scholar
Digital Library
- Callum Cameron, Jeremy Singer, and David Vengerov. 2015. The Judgment of Forseti: Economic Utility for Dynamic Heap Sizing of Multiple Runtimes. SIGPLAN Not., 50, 11 (2015), jun, 143–156. issn:0362-1340 https://doi.org/10.1145/2887746.2754180
Google Scholar
Digital Library
- Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle Time Garbage Collection Scheduling. SIGPLAN Not., 51, 6 (2016), Jun, 570–583. issn:0362-1340 https://doi.org/10.1145/2980983.2908106
Google Scholar
Digital Library
- Ulan Degenbaev, Jochen Eisinger, Kentaro Hara, Marcel Hlopko, Michael Lippautz, and Hannes Payer. 2018. Cross-Component Garbage Collection. Proc. ACM Program. Lang., 2, OOPSLA (2018), Article 151, oct, 24 pages. https://doi.org/10.1145/3276521
Google Scholar
Digital Library
- Ulan Degenbaev, Michael Lippautz, and Hannes Payer. 2018. Concurrent marking in V8. https://v8.dev/blog/concurrent-marking
Google Scholar
- Ulan Degenbaev, Michael Lippautz, and Hannes Payer. 2019. Concurrent Marking of Shape-Changing Objects. ISMM 2019. Association for Computing Machinery, New York, NY, USA. 89–102. isbn:9781450367226 https://doi.org/10.1145/3315573.3329978
Google Scholar
Digital Library
- Matthew Flatt. 2022. cs: experiment with a revised major-GC trigger. https://github.com/racket/racket/commit/157b1f30a1501d53d310cbe0d9bb999a81c689e7
Google Scholar
- Matthew Flatt and PLT. 2010. Reference: Racket. PLT Design Inc.. https://racket-lang.org/tr1/
Google Scholar
- Matthew Hertz and Emery D. Berger. 2005. Quantifying the Performance of Garbage Collection vs. Explicit Memory Management. SIGPLAN Not., 40, 10 (2005), Oct, 313–326. issn:0362-1340 https://doi.org/10.1145/1103845.1094836
Google Scholar
Digital Library
- Matthew Hertz, Yi Feng, and Emery D. Berger. 2005. Garbage Collection without Paging. In Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’05). Association for Computing Machinery, New York, NY, USA. 143–153. isbn:1595930566 https://doi.org/10.1145/1065010.1065028
Google Scholar
Digital Library
- Matthew Hertz, Stephen Kane, Elizabeth Keudel, Tongxin Bai, Chen Ding, Xiaoming Gu, and Jonathan E. Bard. 2011. Waste Not, Want Not: Resource-Based Garbage Collection in a Shared Environment. In Proceedings of the International Symposium on Memory Management (ISMM ’11). Association for Computing Machinery, New York, NY, USA. 65–76. isbn:9781450302630 https://doi.org/10.1145/1993478.1993487
Google Scholar
Digital Library
- Richard Jones, Antony Hosking, and Eliot Moss. 2012. The Garbage Collection Handbook (1 ed.). Chapman and Haii/CRC, Taylor and Francis Group, 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742.
Google Scholar
- Marisa Kirisame, Steven Lyubomirsky, Altan Haan, Jennifer Brennan, Mike He, Jared Roesch, Tianqi Chen, and Zachary Tatlock. 2021. Dynamic Tensor Rematerialization. In International Conference on Learning Representations. 31 pages. https://doi.org/10.48550/ARXIV.2006.09616
Google Scholar
- David Lion, Adrian Chiu, and Ding Yuan. 2021. M3: End-to-End Memory Management in Elastic System Software Stacks. In Proceedings of the Sixteenth European Conference on Computer Systems (EuroSys ’21). Association for Computing Machinery, New York, NY, USA. 507–522. isbn:9781450383349 https://doi.org/10.1145/3447786.3456256
Google Scholar
Digital Library
- John McCarthy. 1960. Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I. Commun. ACM, 3, 4 (1960), apr, 184–195. issn:0001-0782 https://doi.org/10.1145/367177.367199
Google Scholar
Digital Library
- Mozilla. 2020. Are We Slim Yet. http://udn.realityripple.com/docs/Mozilla/Performance/AWSY
Google Scholar
- Mozilla. 2022. FireFox MemBalancer. https://bugzilla.mozilla.org/show_bug.cgi?id=1770763
Google Scholar
- Diogenes Nunez, Samuel Z. Guyer, and Emery D. Berger. 2016. Prioritized garbage collection: explicit GC support for software caches. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, part of SPLASH 2016, Amsterdam, The Netherlands, October 30 - November 4, 2016, Eelco Visser and Yannis Smaragdakis (Eds.). ACM, 695–710. https://doi.org/10.1145/2983990.2984028
Google Scholar
Digital Library
- Oracle. 2015. Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide. https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/
Google Scholar
- Xinli Shang. 2020. Tricks of the trade: Tuning JVM memory for large-scale services. https://eng.uber.com/jvm-tuning-garbage-collection/
Google Scholar
- Ayush Vij. 2022. Reduce chrome memory usage and make it use less Ram. https://www.thewindowsclub.com/reduce-chrome-memory-usage-make-it-use-less-ram
Google Scholar
- Ting Yang, Matthew Hertz, Emery D. Berger, Scott F. Kaplan, and J. Eliot B. Moss. 2004. Automatic Heap Sizing: Taking Real Memory into Account. In Proceedings of the 4th International Symposium on Memory Management (ISMM ’04). Association for Computing Machinery, New York, NY, USA. 61–72. isbn:1581139454 https://doi.org/10.1145/1029873.1029881
Google Scholar
Digital Library
- Chengliang Zhang, Kirk Kelsey, Xipeng Shen, Chen Ding, Matthew Hertz, and Mitsunori Ogihara. 2006. Program-Level Adaptive Memory Management. In Proceedings of the 5th International Symposium on Memory Management (ISMM ’06). Association for Computing Machinery, New York, NY, USA. 174–183. isbn:1595932216 https://doi.org/10.1145/1133956.1133979
Google Scholar
Digital Library
Index Terms
Optimal heap limits for reducing browser memory use
Recommendations
Controlling garbage collection and heap growth to reduce the execution time of Java applications
In systems that support garbage collection, a tension exists between collecting garbage too frequently and not collecting it frequently enough. Garbage collection that occurs too frequently may introduce unnecessary overheads at the risk of not ...
Idle time garbage collection scheduling
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationEfficient garbage collection is increasingly important in today's managed language runtime systems that demand low latency, low memory consumption, and high throughput. Garbage collection may pause the application for many milliseconds to identify live ...
A generational on-the-fly garbage collector for Java
PLDI '00: Proceedings of the ACM SIGPLAN 2000 conference on Programming language design and implementationAn on-the-fly garbage collector does not stop the program threads to perform the collection. Instead, the collector executes in a separate thread (or process) in parallel to the program. On-the-fly collectors are useful for multi-threaded applications ...






Comments