[fixed]Mem Leak: ITexture->lock()

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
EViruS
Posts: 19
Joined: Sat Jul 07, 2007 8:32 pm

[fixed]Mem Leak: ITexture->lock()

Post by EViruS »

Memory leak inside:
void *pTexData = pTexture->lock();
pTexture->unlock();
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

ITexture->lock() is pure virtual, moreover the code seems to be ok. Could you explain a little more?
EViruS
Posts: 19
Joined: Sat Jul 07, 2007 8:32 pm

Post by EViruS »

hybrid wrote:ITexture->lock() is pure virtual, moreover the code seems to be ok. Could you explain a little more?
I use Direct3D9 debug runtime and this two lines contain memory leak, which detected by D3D9 debuger.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The D3D8/9 Implementations of lock definitely do leak when dealing with a RTT. The surface needs to be released. Have a look here.

Travis
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Is it possible to unlock the surface when the RTTSurface is still being locked, or do I have to keep both locked?
zet.dp.ua
Posts: 66
Joined: Sat Jul 07, 2007 8:10 am

Post by zet.dp.ua »

from DX9SDK:

IDirect3DDevice9::GetRenderTargetData
Copies the render-target data from device memory to system memory.

seems what surface can be release after GetRenderTargetData was called
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes, it is safe to Release() as soon as GetRenderTaretData() has returned.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

I think the same happens in openGL... how do I get rid of the data?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The opengl driver creates a copy internally. This is not released until destruction of the RTT, but it will also not leak. So it's not really a bug, but a missing feature. There's already a ticket for this problem. We simply need more flags for the texture generation and handling.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

wait so if I generate 500 cubemaps for SH computation and not delete and re-create the RTT I will leak 1GB?? This is gonna slow me down real BAD
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, you don't leak that memory. It's just a copy in CPU memory. It might be the case that if you create RTT and not lock it, you even don't have a mem copy. Check sources to be sure.
Post Reply