Table of Contents

Keeping memory usage low

There are numerous techniques to reduce memory usage in the SDK and the SpeedTree Modeler application. To monitor how much heap space and vertex/index buffer memory the SDK is using, see Tracking Resource Usage. To reduce areas of possible excess memory use, follow these guidelines.

Geometry and the Core library

Loading .stsdk files can consume a fair amount of memory (specifically, the size of the .stsdk file reflects that amount of RAM it will take to load), but there are some measures that can be taken to reduce memory usage after the .stsdk file is loaded:

  1. After querying the tree's geometry to build your application's vertex and index buffers, call CCore::DeleteGeometry() on the loaded object to delete the internal copies of the vertex and index buffers, which represent the bulk of the memory allocated by the load function.

  2. In addition to keeping art assets of reasonable size, using the smallest number of unique .stsdk files in a scene is also recommended (note that this does not restrict the number of trees/instances in a scene, only the number of unique/base trees). Not only will it reduce the amount of memory used, but it will increase the speed of the forest renders through a reduction in state changes. A few unique .stsdk files in a given forest can go along way if varied rotations and scales are used.

  3. If you're done using the SpeedTree SDK at any point in the application, call CCore::ShutDown(). It's a static function that will clear up the last remaining memory used by the SDK.

Geometry and the Modeler

There are a number of steps that artists can take to lower memory usage when creating assets in the SpeedTree Modeler.

Forest library

Outside of the Core library, where per-tree memory costs are paramount, the Forest library's memory consumption is directly related to the number of visible tree/grass instances.

Draw distance

A common mistake is employing too large a draw distance. Long draw distances impact both memory and performance in the following ways:

Heap reserves

Use the heap reserve system in the SDK to set limits for various quantities, receiving warnings in most cases when the limits are exceeded.