Managing memory with SDK Manager
 
 
 

Class KFbxSdkManager is the SDK manager. Its main purpose is to manage memory for FBX by keeping track of which FBX objects have been instantiated and which ones have been destroyed. An FBX application or plug-in typically begins by creating an SDK manager object.

ImportExport.cxx contains a declaration for a global SDK manager object:

// declare global
KFbxSdkManager* gSdkManager = NULL;

It also contains the code to instantiate and initialize the SDK Manager:

// Creates an instance of the SDK manager.
void InitializeSdkManager()
{
 // Create the FBX SDK memory manager object.
 // The SDK Manager allocates and frees memory
 // for almost all the classes in the SDK.
 gSdkManager = KFbxSdkManager::Create();
}

For almost all classes in the FBX SDK, you create an object by calling the class’s Create() method, while passing your SDK manager object as a parameter. Here, for example, is how ImportExport() creates its KFbxScene object:

// Create a scene
KFbxScene* lScene = KFbxScene::Create(gSdkManager,"");

And here is how LoadScene creates its KFbxImporter object:

 // Create an importer.
    KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,"");

The SDK manager is responsible for allocating memory for the new FBX object. Later, when you no longer need the object, the SDK manager destroys it, and makes the freed-up memory available for another object (see Cleaning up and shutting down).