PathEngine home previous: Handling Attributesnext: Working with the TestBed
Contents, Programmers Guide, Applying the SDK, Miscellaneous API Issues, Memory Tracking

Memory Tracking

PathEngine can optionally be built with instrumentation to track the amount of dynamic memory allocated.

You can test whether or not instrumentation is available for a given build by checking the version attributes for that build.
The 'memory_tracking_enabled' attribute is set to true for builds with the instrumentation enabled. For builds without the instrumentation, this attribute is omitted.
The following code snippets shows how you might test for this attribute:

bool memoryTrackingEnabled = false;
{
    const char *const* attributes = pathengine->getVersionAttributes();
    while(attributes && *attributes)
    {
        if(strcmp(attributes[0], "memory_tracking_enabled") == 0 &&
            strcmp(attributes[1], "true") == 0)
        {
            memoryTrackingEnabled = true;
        }
        attributes += 2;
    }
}

Memory tracking is enabled as standard for the standalone dll, but not for the testbed.

When memory tracking is enabled, the iPathEngine::totalMemoryAllocated() and iPathEngine::maximumMemoryAllocated() methods provide access to the information provided by the instrumentation.
iPathEngine::resetMaximumMemoryAllocated() enables you to determine the peak memory usage within a given operation.

The memory tracking works by tagging a size onto each piece of memory that gets allocated. This instrumentation therefore increases the actual amount of memory allocated, and in circumstances where lots of small allocations are made, this increase can be significant.
The size consumed by the instrumentation itself is not included in the totals.
It is advisable therefore to use this instrumentation purely as a debugging aid. As long as the memory tracking isn't integrated into the functionality of your application you can remove the overhead for instrumentation by switching to a release build without instrumentation.


Documentation for PathEngine release 5.18 - Copyright © 2002-2008 PathEnginenext: Working with the TestBed