Using Cyclic Memory Allocation to Eliminate Memory Leaks
Author(s)
Nguyen, Huu Hai; Rinard, Martin C.
DownloadCS018.pdf (109.4Kb)
Metadata
Show full item recordAbstract
We present and evaluate a new memory management technique for eliminating memory leaks in programs with dynamic memory allocation. This technique observes the execution of the program on a sequence of training inputs to find m-bounded allocation sites, which have the property that at any time during the execution of the program, the program only accesses the last m objects allocated at that site. The technique then transforms the program to use cyclic memory allocation at that site: it preallocates a buffer containing m objects of the type allocated at that site, with each allocation returning the next object in the buffer. At the end of the buffer the allocations wrap back around to the first object. Cyclic allocation eliminates any memory leak at the allocation site - the total amount of memory required to hold all of the objects ever allocated at the site is simply m times the object size.
We evaluate our technique by applying it to several widely-used open source programs. Our results show that it is able to successfully eliminate important memory leaks in these programs. A potential concern is that the estimated bounds m may be too small, causing the program to overlay live objects in memory. Our results indicate that our bounds estimation technique is quite accurate in practice, providing incorrect results for only one of the 161 m-bounded sites that it identifies. To further evaluate the potential impact of overlaying live objects, we artificially reduce the bounds at other m-bounded sites and observe the resulting behavior. The general pattern that emerges is that overlaying elements of core data structures may make the program fail. Overlaying application data, however, may impair parts of the functionality but does not prevent the program from continuing to execute to correctly deliver the remaining functionality.
Date issued
2006-01Series/Report no.
Computer Science (CS)
Keywords
Cyclic memory allocation, memory leak