[solved] mem leakage in GetOption "PageGetTileVertexDat

socke

12-09-2006 20:52:24

it seems that Option "PageGetTileVertexData_2" allocates memory for the index buffer that isn't deleted on exit or anywhere before.
Do i have to clean up anything ?

Reported leakage in ogreleak.log:

3 memory leaks found:

Alloc. Addr Size Addr Size BreakOn BreakOn
Number Reported Reported Actual Actual Unused Method Dealloc Realloc Allocated by
------ ---------- ---------- ---------- ---------- ---------- -------- ------- ------- ---------------------------------------------------
033401 0x0722E850 0x00000014 0x0722E840 0x00000034 0x00000000 new N N OgrePagingLandScapeIndexBuffer.cpp(205) Ogre::PagingLandScapeIndexBufferManager
033402 0x0723AF80 0x00000038 0x0723AF70 0x00000058 0x00000000 new N N ogred3d9hardwarebuffermanager.cpp(100) Ogre::D3D9HardwareBufferManager::create
033404 0x0723B068 0x00000004 0x0723B058 0x00000024 0x00000000 new N N ogresharedptr.h(59) Ogre::SharedPtr<class Ogre::HardwareInd


Code generating the leak


size_t pageX=event->mPagex;
size_t pageZ=event->mPagez;
size_t tileX=event->mTilex;
size_t tileZ=event->mTilez;

std::vector<void*> params;
int renderLevel=0;
params.push_back(&pageX);
params.push_back(&pageZ);
params.push_back(&tileX);
params.push_back(&tileZ);
params.push_back(&renderLevel);
mSceneMgr->getOption("PageGetTileVertexData_2",&params);

int* numVtx=((int*)params[5]);
Ogre::Vector3* vertices=((Ogre::Vector3*)params[6]);
Ogre::IndexData* indexData=((Ogre::IndexData*)params[7]);

//cleanup as mentioned in PLSM2 code
delete[] vertices;
delete numVtx;

HexiDave

12-09-2006 22:07:13

Ya, you'll have to delete it yourself, just check to see if it still exists before you do:
if(indexData)
delete indexData;


I'm sure you can figure out where you need to put it.

socke

13-09-2006 22:58:35

thanks for the answer.
As the index buffer is allocated only once and lasts the whole prog life time i am deleting it now on closure ( i am always asking for LOD 0).

i propose to update the following comments in ogrepaginglandscapescenemanager.cpp. They only mention the deletion of the vertices buffer.

if (strKey == "PageGetTileVertexData_2")
{
/**
* This is the optimized, yet a bit fuzzy implementation of the getVertexDataPatch
* Usage: Pass in a std::vector<void*> Pointer to the getOption call containing at least 5 Elements
* [0](Ogre::unsigned int*) = X Index of the Page to retrieve data from
* [1](Ogre::unsigned int*) = Z Index of the Page to retrieve data from
* [2](Ogre::unsigned int*) = X Index of the Tile within the Page to retrieve data from
* [3](Ogre::unsigned int*) = Z Index of the Tile within the Page to retrieve data from
* [4](Ogre::unsigned int*) = LodLevel to get the data at (note that level 0 means highest detail)
* The getData call will then append 3 entries to the end of the vector. In Detail(in order)
* [End-2](Ogre::unsigned int*) = Number of vertices returned
* [End-1] (Ogre::Vector3*) = The actual vertices, this is a array containing as many elements as returned in [End-2]
* [End] (Ogre::IndexData*) = The index data for the terrain polygons at the queried LodLevel
* @remark note that the caller is in charge of deleting the vector array
*/

tuan kuranes

15-09-2006 08:30:13

done. soon in cvs and next sdk, thanks for pointing that out.