Heap Analysis

If you develop a program that dynamically allocates memory,
you're also responsible for tracking any memory that you allocate whenever a task is performed,
and for releasing that memory when you no longer need it.
If you fail to track the memory correctly, you may introduce
"memory leaks"
or unintentionally write to an area outside of the memory space.

Conventional debugging techniques usually prove to be ineffective for locating
the source of corruption or leaks because memory-related errors typically manifest themselves
in an unrelated part of the program.
Tracking down an error in a multithreaded environment becomes even more complicated
because the threads all share the same memory address space.

In this chapter, we'll describe how QNX Neutrino manages the heap and
introduce you to some techniques
that can help you to diagnose your memory management problems.

Heap corruption
Heap corruption occurs when a program damages the allocator's view of the heap.

Detecting and reporting errors
The primary goal for detecting heap corruption problems is to correctly identify the source of the error, to avoid getting a fault in the allocator at some later point in time.

Manual checking (bounds checking)
There are times when it may be desirable to obtain information about a particular heap buffer or print a diagnostic or warning message related to that heap buffer.