Usually I come across relatively well written pieces of code. That is code that is broken up with 50-60 lines per function and not 1000+ line long functions. Recently I was given a code written by a scientist (I think he is a physicist), and it does some rather clever stuff scientifically. However everything is in one big main() function.

The code mostly ran, and occassionally failed with no apparent reason. The first few things I did was to format/indent the code as much as I could and I started to replace all the malloc/free and some of the string functions with wrapper functions to sanitise everything.

It then occured to me that I should probably run the code through valgrind or something similar to debug the malloc/free calls. Traditionally I would have used electricfence during testing, bug fixing and development. I saw this opportunity to see what else is out there. I had known about gc for a while but never really got around to using it, I'm quite happy to say that it's pretty easy to use and it seems okay for doing garbage collection. It is particularly useful but requires a small bit of work with existing codes.

I was however surprised with google-perftools, I had never realised that it was a malloc() replacement and that it provided a bunch of profiling and checking features. Best of all it is relatively easy to use, short and concise. I've yet to read up on the garbage collection features in this library, assuming there is garbage collection. I can see myself using this library a bit more when I write C or when I have to fix someone elses code.


Related posts:

Alternatives to using GOLD, Maui for accounting and banking for HPC systems
Posted

The ultimate sandbox game, ever!
Posted

Creating a git branch with no ancestry
Posted

Using gource to visualise projects stored in version control
Posted

git-annex and tahoe-lafs as a special remote
Posted

Bookmark and Share