User Tools

Site Tools

Memory Setup

Memory management is an important part of the SpeedTree SDK and the reference application shows how to use these features.

Allocator Interface

The SpeedTree allocator interface is used to redirect all SDK heap allocations to a single point. In the reference application, this is done if ST_USE_ALLOCATOR_INTERFACE is #defined in each platform's main file (e.g. MyMainOpenGL.cpp). It is defined by default and must be used for Debug MT and Release MT builds.

An example allocator class, CMyCustomAllocator, can be found in MyCustomAllocator.h.

Overriding New and Delete

While a library cannot override global new and delete, it is sometimes useful to do in the reference application, if for nothing else than to ensure that all SDK heap allocations are indeed being redirected through the allocator interface. Keep this in mind if you plan to modify the SDK, especially if you're adding heap allocations.

The new and delete operators are overridden if ST_OVERRIDE_GLOBAL_NEW_AND_DELETE is #defined in each platform's main file (e.g. MyMainDX11.cpp). It is off by default.

The overridden operators can be found in MyCustomAllocator.h.