|
Garbage Collection And C
By Doug Caverly
Staff Writer
Article Date: 2009-08-20
Garbage collection is an extremely undervalued aspect of modern society. After all, we couldn't be buzzing around in hybrids and enjoying our plasma TVs if we were buried in filth and suffering from the plague. So today, let's take a look at garbage collection in C-language code applications.
However much you love C, one thing that's hard to deny is that it doesn't provide native garbage collection. Steve Rhoads explained, "The lack of a garbage collector could be considered a limitation of C. However, it is possible to implement a trivial garbage collector if we are willing to live with a few limitations."
Rhoads then got into a couple technical series of instructions that we'll allow you to peruse for yourself. The key point is that, when all's said and done, you'll wind up further from a (figurative) trashy state.
Rhoads concluded, "This trivial garbage collector implementation enables the developer to focus on the algorithm and data structures instead of worrying about memory leaks. The garbage collector could be improved by adding semaphore protection to support multiple threads, and by placing an additional magic value at the end of all allocated memory blocks to better detect heap corruption."
And considering how much easier this tinkering is than the real garbage collection deal - running around in the street, hauling bags of smelly stuff - there's no excuse for not doing it.
About the Author:
Doug is a staff writer for WebProNews. Visit WebProNews for the latest eBusiness news.
|