Heap analysis

There are two basic modes of operation:

Heap monitoring Heap analysis
Reports each event in the heap. Keeps and reports data for blocks currently in the heap or most recently deleted.
Reports more data; generates a larger data file. Reports less data; generates a smaller data file.
Runs slower. Runs faster.
Does not detect problems. Detects problems, such as double deletion.

To use the local heap tools, modify your code to instantiate a heap tool object, using either TLocalHeapMonitor or TLocalHeapAnalyzer. Once the object is instantiated, monitoring or analysis starts. When you destroy the object (such as if it goes out of scope), monitoring or analysis stops.

Consider a class called TLeaksLikeASieve, which leaks storage when its Leak() method is called. The following code starts monitoring, calls the suspect method, and then automatically stops monitoring when the monitor object goes out of scope:

      #include <LocalHeapMonitor.h>          // for TLocalHeapMonitor
      void main()
      {
          // Start monitoring; continue until object 'monitor' is destroyed.
          TLocalHeapMonitor monitor;
          TLeaksLikeASieve leaker;
          leaker.Leak();
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker