Hi,
I'm wondering if the following steps would create a memory leak on GPU side:
1. Create an SMeshBuffer with some content
2. Use setHardwareMappingHint(EHM_STATIC)
3. Render it many times via IVideoDriver::drawMeshBuffer
4. Delete the SMeshBuffer
I believe the Vertex Buffer Objects still persist although they are never used again and therefore are a memory leak on GPU side.
Is this correct? If yes: How do I properly handle this situation?
GPU side memory leak?
Re: GPU side memory leak?
I believe I found the solution: IVideoDriver::removeHardwareBuffer must be called to avoid the memory leak when deleting the meshbuffer.
Btw: After looking at the code of CMeshCache::removeMesh I believe I found a bug. This function does not remove the hardware buffers when deleting a mesh:
Btw: After looking at the code of CMeshCache::removeMesh I believe I found a bug. This function does not remove the hardware buffers when deleting a mesh:
Code: Select all
void CMeshCache::removeMesh(const IMesh* const mesh)
{
if ( !mesh )
return;
for (u32 i=0; i<Meshes.size(); ++i)
{
if (Meshes[i].Mesh == mesh || (Meshes[i].Mesh && Meshes[i].Mesh->getMesh(0) == mesh))
{
Meshes[i].Mesh->drop();
Meshes.erase(i);
return;
}
}
}
Re: GPU side memory leak?
deleteHardwareBuffer is used. Check CNullDriver::updateAllHardwareBuffers() - it has some timeout. Don't know details or reason right now, but basically it's released after 20 seconds.
edit: I suspect there is no reason that it's not release immediately (didn't debug right now - maybe it even is?). The 20 seconds seems to be for another reason. Basically hardwarebuffers are only kept when they are regularly used. So when it's 20 seconds not used it gets kicked and re-created next it _is_ used.
edit: I suspect there is no reason that it's not release immediately (didn't debug right now - maybe it even is?). The 20 seconds seems to be for another reason. Basically hardwarebuffers are only kept when they are regularly used. So when it's 20 seconds not used it gets kicked and re-created next it _is_ used.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm