Heap Shaker

Some environments allocate memory from a heap, using a double-indirect -->handle-->pointer algorithm.

In such environments, there is sometimes a temptation to optimize code by copying and using the pointer, such as when doing a block copy operation. These can create subtle timebombs if the "temporary" pointer is mistakenly passed around instead of the handle. The code will appear to work correctly (even FAST!), until something changes the heap. Then, the code may fail in unexpected, apparently random ways -- because the corrupt pointers are typically not discovered until they are dereferenced, often a very long time after, and in totally different code from, the code that created the problem.

A HeapShaker is a tool that reassigns the contents of every handle, ensuring that such stale pointers fail. It is often combined with a test framework that attempts to dereference and exercise the heap, so that the cycle is shake->test->shake->test.

Those of us who coded the original 128K Mac may remember these with some fondness.


EditText of this page (last edited May 3, 2006) or FindPage with title or text search