ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6
part 7
part 8


5 - Tool #3 - Memory Monitoring

I recently was up late debugging a program that was screwing up dice throws. The first five were working, but the last seven were behaving strangely. None of my test code was working, and I was really getting quite frustrated, when I realized that Yatchzee only uses five dice…

Memory issues abound in C/C++. Part of the reason Java is so successful is because it does away with pointers, and the associated pointer problems (which also contributes to its slowness).

Catching the dice problem would have been trivial with a memory check tool, since it would tell me I was trying to access seven phantom array elements. With that in mind, I decided to write a memory check utility for the ebm. Based on the various memory validators floating around the Internet, it tries to monitor memory as closely as possibly, allowing you to catch many errors early.

The theory behind it is simple. When a chunk of memory is allocated, these routines piggyback additional information. The information is in the form of guard bytes, memory data, source information, etc - all with the goal of making the malloc more data-aware (there's versions for realloc and calloc as well).

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice