Generating a Heap Report

The SpeedTree SDK has a mechanism for generating a report that describes every heap allocation made by the SDK and anything else that uses the memory management functions in Core/Memory.h. This includes virtually everything in the reference application, save heap allocations made by other libraries used there (DXUT, glut, glew, etc.) and the graphics API themselves. All of the SpeedTree-related classes in the reference application are set up to use the SDK memory interface.

This section of the document details how to generate a report of every heap allocation routed through this interface. This report is also a good way to track memory leaks for anything that's using the allocation interface. Imbalanced new/delete calls will be revealed in the report.


Generating a Report

You must recompile the SpeedTree SDK in order to generate a report. Enable heap allocation tracking by #defining ST_MEMORY_STATS at the top of Allocator.h in the Core library (it is there by default, commented out). Comment in #define ST_MEMORY_STATS_VERBOSE back in for a very detail heap allocation report (warning: it can be lengthy).

Note: Please be sure to comment ST_MEMORY_STATS and ST_MEMORY_STATS_VERBOSE out when performance is a concern, as they will add overhead to the SDK's execution.

The next step will be to make a single call from within the client engine or application:

#include "Core/Memory.h"
using namespace SpeedTree;
 
...
 
CAllocator::Report("my_report.csv", true);

Notes