Abstract
Garbage collection greatly improves programmer productivity and ensures memory safety. Manual memory management on the other hand often delivers better performance but is typically unsafe and can lead to system crashes or security vulnerabilities. We propose integrating safe manual memory management with garbage collection in the .NET runtime to get the best of both worlds. In our design, programmers can choose between allocating objects in the garbage collected heap or the manual heap. All existing applications run unmodified, and without any performance degradation, using the garbage collected heap.
Our programming model for manual memory management is flexible: although objects in the manual heap can have a single owning pointer, we allow deallocation at any program point and concurrent sharing of these objects amongst all the threads in the program. Experimental results from our .NET CoreCLR implementation on real-world applications show substantial performance gains especially in multithreaded scenarios: up to 3x savings in peak working sets and 2x improvements in runtime.
- Periklis Akritidis. 2010. Cling: A Memory Allocator to Mitigate Dangling Pointers.. In USENIX Security Symposium. 177–192.Google Scholar
- Dan Alistarh, William M. Leiserson, Alexander Matveev, and Nir Shavit. 2015. ThreadScan: Automatic and Scalable Memory Reclamation. In SPAA.Google Scholar
- ASP.Net. 2017. ASP.Net/Caching: Libraries for in-memory caching and distributed caching. https://github.com/aspnet/ Caching . (2017).Google Scholar
- David F. Bacon, Clement R. Attanasio, Han B. Lee, V. T. Rajan, and Stephen Smith. 2001. Java Without the Coffee Breaks: A Nonintrusive Multiprocessor Garbage Collector. PLDI (2001).Google Scholar
Digital Library
- David F. Bacon, Perry Cheng, and V.T. Rajan. 2003. The Metronome: A Simpler Approach to Garbage Collection in Real-time Systems. In In Workshop on Java Technologies for Real-Time and Embedded Systems (JTRES), OTM Workshops. Google Scholar
Cross Ref
- Henry G. Baker. 1995. Use-once variables and linear objects–storage management, reflection, and multi-threading. SIGPLAN Notices 30, 1 (January 1995), 45–52. Google Scholar
Digital Library
- Oana Balmau, Rachid Guerraoui, Maurice Herlihy, and Igor Zablotchi. 2016. Fast and Robust Memory Reclamation for Concurrent Data Structures. In SPAA. Google Scholar
Digital Library
- Emery D Berger and Benjamin G Zorn. 2006. DieHard: probabilistic memory safety for unsafe languages. In Acm sigplan notices, Vol. 41. ACM, 158–168.Google Scholar
- S. M. Blackburn and K. S. McKinley. 2008. Immix: a mark-region garbage collector with space efficiency, fast collection, and mutator performance. In PLDI. Google Scholar
Digital Library
- Burton H. Bloom. 1970. Space/Time Trade-offs in Hash Coding with Allowable Errors. Commun. ACM 13, 7 (1970). Google Scholar
Digital Library
- Hans-Juergen Boehm and Mark Weiser. 1988. Garbage Collection in an uncooperative environment. Software – Practice and Experience 18, 9 (1988), 807–820. Google Scholar
Digital Library
- Chandrasekhar Boyapati, Alexandru Salcianu, William Beebee, and Martin Rinard. 2003. Ownership types for safe regionbased memory management in real-time Java. In PLDI.Google Scholar
- John Boyland. 2001. Alias burying: Unique variables without destructive reads. Software – Practice and Experience 31, 6 (2001), 533–553. Google Scholar
Digital Library
- Trevor Alexander Brown. 2015. Reclaiming Memory for Lock-Free Data Structures: There Has to Be a Better Way. In PODC.Google Scholar
- Perry Cheng, Robert Harper, and Peter Lee. 1998. Generational Stack Collection and Profile-driven Pretenuring. In Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation (PLDI ’98). ACM, New York, NY, USA, 162–173. Google Scholar
Digital Library
- Dave Clarke and Tobias Wrigstad. 2003. External uniqueness is unique enough. In ECOOP. 176–200. Google Scholar
Cross Ref
- David G. Clarke, John M. Potter, and James Noble. 1998. Ownership types for flexible alias protection. In OOPSLA. Google Scholar
Digital Library
- Daniel Clifford, Hannes Payer, Michael Stanton, and Ben L. Titzer. 2015. Memento Mori: Dynamic Allocation-site-based Optimizations. In Proceedings of the 2015 International Symposium on Memory Management (ISMM ’15). ACM, New York, NY, USA, 105–117. Google Scholar
Digital Library
- Nachshon Cohen and Erez Petrank. 2015a. Automatic memory reclamation for lock-free data structures. In OOPSLA. Google Scholar
Digital Library
- Nachshon Cohen and Erez Petrank. 2015b. Efficient Memory Management for Lock-Free Data Structures with Optimistic Access. In SPAA. Google Scholar
Digital Library
- CoreCLR. 2017. CoreCLR: the .NET Core runtime. http://www.github.com/dotnet/CoreCLR . (2017).Google Scholar
- Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle Time Garbage Collection Scheduling. In PLDI. Google Scholar
Digital Library
- Dinakar Dhurjati and Vikram Adve. 2006. Efficiently Detecting All Dangling Pointer Uses in Production Servers. In DSN. Google Scholar
Digital Library
- Dinakar Dhurjati, Sumant Kowshik, Vikram Adve, and Chris Lattner. 2003. Memory safety without runtime checks or garbage collection. ACM SIGPLAN Notices 38, 7 (2003), 69–80. Google Scholar
Digital Library
- Dave Dice, Maurice Herlihy, and Alex Kogan. 2016. Fast non-intrusive memory reclamation for highly-concurrent data structures. In ISMM. Google Scholar
Digital Library
- Keir Fraser. 2004. Practical lock-freedom. PhD Thesis UCAM-CL-TR-579. Computer Laboratory, University of Cambridge.Google Scholar
- Lokesh Gidra, Gaël Thomas, Julien Sopena, Marc Shapiro, and Nhan Nguyen. 2015. NumaGiC: a garbage collector for big data on big NUMA machines. In ASPLOS. Google Scholar
Digital Library
- Ionel Gog, Jana Giceva, Malte Schwarzkopf, Kapil Vaswani, Dimitrios Vytiniotis, Ganesan Ramalingam, Manuel Costa, Derek Gordon Murray, Steven Hand, and Michael Isard. 2015. Broom: Sweeping Out Garbage Collection from Big Data Systems. In HotOS.Google Scholar
- Dan Grossman, Greg Morrisett, and Trevor Jim. 2002. Region-based Memory Management in Cyclone. In PLDI. Google Scholar
Digital Library
- Timothy L. Harris. 2000. Dynamic Adaptive Pre-tenuring. In Proceedings of the 2Nd International Symposium on Memory Management (ISMM ’00). ACM, New York, NY, USA, 127–136. Google Scholar
Digital Library
- Timothy L. Harris. 2001. A Pragmatic Implementation of Non-blocking Linked-Lists. In DISC. Google Scholar
Cross Ref
- Thomas E. Hart, Paul E. McKenney, Angela Demke Brown, and Jonathan Walpole. 2007. Performance of memory reclamation for lockless synchronization. Journal of Parallel and Distributed Computing 67 (May 2007), 1270–1285. Google Scholar
Digital Library
- Matthew Hertz and Emery D. Berger. 2005. Quantifyng the Performance of Garbage Collection vs. Explicit Memory Management. In OOPSLA.Google Scholar
- Michael Hicks, Greg Morrisett, Dan Grossman, and Trevor Jim. 2004. Experience With Safe Manual Memory-Management in Cyclone. In ISMM. Google Scholar
Digital Library
- John Hogg. 1991. Islands: Aliasing protection in object-oriented languages. In OOPSLA.Google Scholar
- Robert Hundt. 2011. Loop Recognition in C++/Java/Go/Scala. In Proceedings of Scala Days 2011.Google Scholar
- Richard Jones, Antony Hosking, and Eliot Moss. 2011. The Garbage Collection Handbook: The Art of Automatic Memory Management (1st ed.). Chapman & Hall/CRC.Google Scholar
- Piyus Kedia, Manuel Costa, Matthew Parkinson, Kapil Vaswani, and Dimitrios Vytiniotis. 2017. Simple, fast and safe manual memory management. In PLDI. Google Scholar
Digital Library
- Byoungyoung Lee, Chengyu Song, Yeongjin Jang, and Tielei Wang. 2015. Preventing Use-after-free with Dangling Pointer Nullification. In NDSS. Google Scholar
Cross Ref
- Vitaliy B. Lvin, Gene Novark, Emery D. Berger, and Benjamin G. Zorn. 2008. Archipelago: trading address space for reliability and security. In ASPLOS. Google Scholar
Digital Library
- Martin Maas, Krste Asanović, Tim Harris, and John Kubiatowicz. 2016. Taurus: A Holistic Language Runtime System for Coordinating Distributed Managed-Language Applications. In ASPLOS. Google Scholar
Digital Library
- Maged M. Michael. 2004. Hazard Pointers: Safe Memory Reclamation for Lock-Free Objects. IEEE Transactions on Parallel and Distributed Systems 15, 6 (June 2004), 491–504. Google Scholar
Digital Library
- T. Minka, J.M. Winn, J.P. Guiver, S. Webster, Y. Zaykov, B. Yangel, A. Spengler, and J. Bronskill. 2014. Infer.NET 2.6. (2014). Microsoft Research Cambridge. http://research.microsoft.com/infernet.Google Scholar
- Naftaly Minsky. 1996. Towards alias-free pointers. In ECOOP. 189–209. Google Scholar
Cross Ref
- Adam Morrison and Yehuda Afek. 2015. Temporally Bounding TSO for Fence-Free Asymmetric Synchronization. In ASPLOS. Google Scholar
Digital Library
- MSDN. 2016. Asynchronous Programming with async and await. https://msdn.microsoft.com/en-us/library/mt674882.aspx . (2016).Google Scholar
- Karl Naden, Robert Bocchino, Jonathan Aldrich, and Kevin Bierhoff. 2012. A Type System for Borrowing Permissions. In POPL. Google Scholar
Digital Library
- Santosh Nagarakatte, Jianzhou Zhao, Milo M. K. Martin, and Steve Zdancewic. 2010. CETS Compiler-Enforced Temporal Safety for C. In ISMM.Google Scholar
- Khan Nguyen, Lu Fang, Guoqing Xu, Brian Demsky, Shan Lu, Sanazsadat Alamian, and Onur Mutlu. 2016. Yak: A High Performance Big-Data-Friendly Garbage Collector. In OSDI.Google Scholar
- Khanh Nguyen, Kai Wang, Yingyi Bu, Lu Fang, Jianfei Hu, and Guoqing Xu. 2015. FACADE: A Compiler and Runtime for (Almost) Object-Bounded Big Data Applications. In ASPLOS.Google Scholar
Digital Library
- Gene Novark and Emery D Berger. 2010. DieHarder: securing the heap. In Proceedings of the 17th ACM conference on Computer and communications security. ACM, 573–584. Google Scholar
Digital Library
- Matthew Parkinson, Dimitrios Vytiniotis, Kapil Vaswani, Manuel Costa, Pantazis Deligiannis, Dylan McDermott, Aaron Blankstein, and Jonathan Balkind. 2017. Project Snowflake: Safe Manual Memory Management in .NET. Technical Report MSR-TR-2017-32. Microsoft Research. https://www.microsoft.com/en-us/research/wp-content/uploads/2017/07/ snowflake-extended.pdfGoogle Scholar
- Fred Smith, David Walker, and Greg Morrisett. 2000. Alias types. In European Symposium on Programming (ESOP). Google Scholar
Cross Ref
- Codruţ Stancu, Christian Wimmer, Stefan Brunthaler, Per Larsen, and Michael Franz. 2015. Safe and Efficient Hybrid Memory Management for Java. In ISMM. Google Scholar
Digital Library
- D. Stefanovic, K. S. McKinley, and J. E. B. Moss. 1999. Age-based garbage collection. In OOPSLA. Google Scholar
Digital Library
- Nikhil Swamy, Michael Hicks, Greg Morrisett, Dan Grossman, and Trevor Jim. 2006. Safe Manual Memory-Management in Cyclone. Science of Computer Programming 62, 2 (October 2006), 122–14. Google Scholar
Digital Library
- Gil Tene, Balaji Iyengar, and Michael Wolk. 2011. C4: The Continuously Conucrrent Compacting Collector. In ISMM. Google Scholar
Digital Library
- Mads Tofte and Jean-Pierre Talpin. 1997. Region-based memory management. Information and Computation 132, 2 (February 1997), 109–176. Google Scholar
Digital Library
- TPC.org. 2017. The TPC Benchmark T M H. http://www.tpc.org/tpch . (2017).Google Scholar
- Philip Wadler. 1990. Linear types can change the world!. In IFIP TC 2 Working Conference.Google Scholar
- David Walker, Karl Crary, and Greg Morrisett. 2000. Typed memory management in a calculus of capabilities. ACM Transactions on Programming Languages and Systems 24, 4 (2000), 701–771. Google Scholar
Digital Library
- David Walker and Kevin Watkins. 2001. On regions and linear types. In ICFP.Google Scholar
- Yves Younan. 2015. FreeSentry: protecting Against User-After-Free Vulnerabilities Due to Dangling Pointers. In NDSS. Google Scholar
Cross Ref
- B. G. Zorn. 1993. The measured cost of conservative garbage collection. Software – Practice and Experience 23, 7 (1993), 733–756. Google Scholar
Digital Library
Index Terms
Project snowflake: non-blocking safe manual memory management in .NET
Recommendations
Safe manual memory management
ISMM '07: Proceedings of the 6th international symposium on Memory managementWe present HeapSafe, a tool that uses reference counting to dynamically verify the soundness of manual memory management of C programs. HeapSafe relies on asimple extension to the usual malloc/free memory management API: delayed free scopes during which ...
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 ...
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 ...






Comments