Hi,
I got a problem of memory leak on the 1.5 svn branch with "12.TerrainRendering_vc8".
If I activate "Debug D3D9 Runtime", and I run example 12 in debug mode from Visual C++ 2005, then I move the camera and quit, then I can see a bunch of memory leak at the end.
It seems the terrain generate thoses memory leak, and it doesn't allow me to reset my device inside my own program when I'm using this terrain.
Does someone got a clue about it ? or/and a solution ?
ps: It seems link to the Hardware Buffer.
[fixed]Terrain:D3D Memory Leak Problem (12.TerrainRendering)
[fixed]Terrain:D3D Memory Leak Problem (12.TerrainRendering)
Last edited by Ti-R on Thu Mar 26, 2009 5:09 pm, edited 1 time in total.
Just to help a bit.
If I comment thoses 2 lines to disable HardwareMapping
The memory leak disappear.
Thanks hybrid for the reply
If I comment thoses 2 lines to disable HardwareMapping
Code: Select all
CTerrainSceneNode::CTerrainSceneNode(...)
{
...
RenderBuffer = new CDynamicMeshBuffer(video::EVT_2TCOORDS, video::EIT_16BIT);
// RenderBuffer->setHardwareMappingHint(scene::EHM_STATIC, scene::EBT_VERTEX);
// RenderBuffer->setHardwareMappingHint(scene::EHM_DYNAMIC, scene::EBT_INDEX);
...
}
Thanks hybrid for the reply
Hi,
I'm trying to patch irrlicht 1.5 to fix this bug.
I find out irrlicht is creating a lot of IndexBuffer for the terrain LOD because the size of index is increasing following the camera position. It result having lot of IndexBuffer unrelease.
I just add
Same for VertexBuffer
Now D3D reset is working perfectly.
But in D3D Debug mode, I still see when I quit my program some memoryleak (If I comment both setHardwareMappingHint, like say before, they go away...! )
Any clue to correct this fix, did I miss something to free correctly buffer ?
BTW, I check that SetStreamSource(0, 0, 0, 0) & SetIndices(0) are always call after been set.
I'm trying to patch irrlicht 1.5 to fix this bug.
I find out irrlicht is creating a lot of IndexBuffer for the terrain LOD because the size of index is increasing following the camera position. It result having lot of IndexBuffer unrelease.
I just add
Code: Select all
bool CD3D9Driver::updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer)
{
//...
/// (BEGIN) Patch (if indexBuffer exist, release it before to create a new one) ---- Ti-R ----
if(HWBuffer->indexBuffer)
{
HWBuffer->indexBuffer->Release();
HWBuffer->indexBuffer=0;
}
/// (END) Patch (if indexBuffer exist, release it before to create a new one) ---- Ti-R ----
if(FAILED(pID3DDevice->CreateIndexBuffer( indexCount * indexSize, flags, indexType, D3DPOOL_DEFAULT, &HWBuffer->indexBuffer, NULL)))
//...
}
Code: Select all
bool CD3D9Driver::updateVertexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer)
{
//...
/// (BEGIN) Patch (if vertexBuffer exist, release it before to create a new one) ---- Ti-R ----
if(HWBuffer->vertexBuffer)
{
HWBuffer->vertexBuffer->Release();
HWBuffer->vertexBuffer=0;
}
/// (END) Patch (if vertexBuffer exist, release it before to create a new one) ---- Ti-R ----
pID3DDevice->CreateVertexBuffer(vertexCount * vertexSize, flags, FVF, D3DPOOL_DEFAULT, &HWBuffer->vertexBuffer, NULL);
//...
}
But in D3D Debug mode, I still see when I quit my program some memoryleak (If I comment both setHardwareMappingHint, like say before, they go away...! )
Any clue to correct this fix, did I miss something to free correctly buffer ?
BTW, I check that SetStreamSource(0, 0, 0, 0) & SetIndices(0) are always call after been set.
I find the last leak. (The fix I made up is still valid)
Need also to remove the HardwareBuffer by "Hand" inside the
CTerrainSceneNode.
Could be very nice to have an automatic clean up when we drop a Hardware Buffer
Need also to remove the HardwareBuffer by "Hand" inside the
CTerrainSceneNode.
Code: Select all
CTerrainSceneNode::~CTerrainSceneNode()
{
//...
if (RenderBuffer)
{
/// (BEGIN) Patch (Remove HWBuffer by "Hand") ---- Ti-R ----
SceneManager->getVideoDriver()->removeHardwareBuffer(RenderBuffer);
/// (END) Patch (Remove HWBuffer by "Hand") ---- Ti-R ----
RenderBuffer->drop();}
//...
}
Could be very nice to have an automatic clean up when we drop a Hardware Buffer