A garbage collection policy based on empirical behavior
Many C++ studies show that dynamic memory management is one of the most expensive components in many software systems. C++ programs tend to carry out object creation and deletion prolifically. As a result, dynamic memory management can consume up to 30% of the program execution time in C++. In many cases, programmers need automatic dynamic memory management to free them from the problem of having to manage the C++'s large number of memory invocations. Unlike other object-oriented languages, C++ does not contain an automatic memory management policy among its language features. This paper presents a garbage collection strategy, called GC++, which collects garbage automatically with high speed of object allocation/deallocation. This high speed allocation/deallocation come from the utilization of memory allocation/deallocation behavior. The C++ allocation/deallocation patterns are determined experimentally in this paper. The proposed scheme is made feasible by minimizing memory allocation/deallocation calls and reusing objects based on other empirical investigations. To implement GC++, we applied the technique of Smart Pointer, which is one of the standard template containers. Our allocation scheme is simple and fast, since it requires no splitting and coalescing, and reduces the number of malloc() calls. It maintains its own free-list, which is used for object-reuse. Our scheme is purely source-code oriented and built on the top of the normal C++ memory manager. Therefore, this approach is portable, can be applied with existing code and is safe to use with different memory managers.
garbage collection dynamic memory management software system smart pointer