Safe manual memory management
- 21 October 2007
- conference paper
- conference paper
- Published by Association for Computing Machinery (ACM) in Proceedings of the 6th international symposium on Memory management - ISMM '07
Abstract
We present HeapSafe, a tool that uses reference counting to dynamically verify the soundness of manual memory man- agement of C programs. HeapSafe relies on a simple ex- tension to the usual malloc/free memory management API: delayed free scopes during which otherwise dangling refer- ences can exist. Porting programs for use with HeapSafe typ- ically requires little effort (on average 0.6% of lines change), adds an average 11% time overhead (84% in the worst case), and increases space usage by an average of 13%. These re- sults are based on porting over half a million lines of C code, including perl where we found six previously unknown bugs. Many existing C programs continue to use unchecked manual memory management. One reason is that program- mers fear that moving to garbage collection is too big a risk. We believe that HeapSafe is a practical way to provide safe memory management for such programs. Since HeapSafe checks existing memory management rather than changing it, programmers need not worry that HeapSafe will intro- duce new bugs; and, since HeapSafe does not manage mem- ory itself, programmers can choose to deploy their programs without HeapSafe if performance is critical (a simple header file allows HeapSafe programs to compile and run with a regular C compiler). In contrast, we found that garbage col- lection, although faster, had much higher space overhead, and occasionally caused a space-usage explosion that made the program unusable.Keywords
This publication has 14 references indexed in Scilit:
- Backwards-compatible array bounds checking for C with very low overheadPublished by Association for Computing Machinery (ACM) ,2006
- CCured: type-safe retrofitting of legacy softwareACM Transactions on Programming Languages and Systems, 2005
- Memory safety without garbage collection for embedded applicationsACM Transactions on Embedded Computing Systems, 2005
- RacerXPublished by Association for Computing Machinery (ACM) ,2003
- EraserACM Transactions on Computer Systems, 1997
- Static detection of dynamic memory errorsPublished by Association for Computing Machinery (ACM) ,1996
- Efficient detection of all pointer and array access errorsPublished by Association for Computing Machinery (ACM) ,1994
- Garbage collection in an uncooperative environmentSoftware: Practice and Experience, 1988
- Managing Reentrant Structures Using Reference CountsACM Transactions on Programming Languages and Systems, 1980
- An efficient, incremental, automatic garbage collectorCommunications of the ACM, 1976