Tuesday, 4 September 2012

A Garbage Collector For the C Programming Language


INTRODUCTION
C is and has always been one of the most widely and popularly used programming languages in the world. We, as a part of our B.E Degree course have done a lot of programming in C and have always used the built in functions defined in the standard library like “malloc”, “calloc” etc. to allocate memory and when the allocated memory is not needed any more we use the built in function “free” to free up the allocated memory.
                                                 
What we have attempted to improve the functionality of the ‘C’ programming language by developing a library that supports garbage collection. We were inspired by the presence of the GC features in JAVA and proceeded to develop one for C. So now, the ‘C’ programmer is relived of the task of keeping track of what memory locations are currently being referenced and what are not. If the programmer uses our library for allocating memory dynamically, we will make sure (conservatively) that the allocated memory is automatically freed (i.e.) garbage is collected when it is no longer referenced.


Myths about GC

·         GC is necessarily slower than manual memory management.
·         GC will necessarily make my program pause.
·         Manual memory management won't cause pauses.
·         GC is incompatible with C.

Facts about GC

·         Most allocated objects are dynamically referenced by a very small number of
·         Pointers. The most important small number is ONE.
·         Most allocated objects have short lifetimes.
·         Allocation patterns (size distributions, lifetime distributions) are bursts, not uniform.
·         Optimal" strategies can fail miserably.

ARTICLE BY
P.H.S. UMA MAHESHWARI
PRE-FINAL YEAR IT