I managed to track down the memory leak using your help, and it turns out it's not because of the mesh at all! It's because of the texture file which I'm loading! It's a similar case to the Mesh, but I'll provide the important parts of code:
map<LPCWSTR, LPDIRECT3DTEXTURE9*> _textures;
// Gets the number of textures and materials to load
loadedMaterials = (D3DXMATERIAL*) tempMaterialBuffer->GetBufferPointer();
_textures[assetName] = new LPDIRECT3DTEXTURE9[_tempNumMaterials];
_materials[assetName] = new D3DMATERIAL9[_tempNumMaterials];
// For the number of loaded materials
for ( DWORD i = 0; i < _tempNumMaterials; i++ )
{
// Loads the materials
_materials[assetName] = loadedMaterials.MatD3D;
_materials[assetName].Ambient = _materials[assetName].Diffuse;
// Loads the textures
_textures[assetName] = NULL;
if ( loadedMaterials.pTextureFilename != NULL )
{
D3DXCreateTextureFromFileA( gfx3DDevice, loadedMaterials.pTextureFilename, &_textures[assetName] );
}
}
tempMaterialBuffer->Release();
This above piece of code carries on from the LoadMeshFromX call.
Then finally, in the destructor call:
for (map<LPCWSTR, LPDIRECT3DTEXTURE9*>::iterator i = _textures.begin(); i != _textures.end(); ++i)
{
if (i->second != NULL)
{
int numObjects = sizeof(i->second) / sizeof(LPDIRECT3DTEXTURE9*);
for (int j = 0; j < numObjects; ++j)
{
i->second[j]->Release();
}
}
}
I'm going to try and track it down tonight before I head to bed, but if anyone finds anything and wishes to share, would be very much appreciated