Click to See Complete Forum and Search --> : directX double buffering...


chi_luci
March 10th, 2005, 06:50 AM
Have anyone tested the http://www.codeproject.com/directx/dxsurfacemgr.asp method? It provides easy implementation for double buffering with DirectX. The problem is that even the test aplication mfcDx is memory leaking. Just run the app and move it so that is is not entirely visible on the desktop and look in Task Manager -> you'll see you're running out of memory in no time!
can anyone tell me what's wrong there?

Ejaz
March 10th, 2005, 06:56 AM
Did you trythat? (http://www.codeproject.com/directx/dxsurfacemgr.asp#xx61715xx) I guess the author didn't updated the code. :rolleyes:

chi_luci
March 10th, 2005, 08:28 AM
I was wondering if only I have this problem! Maybe it's just my Windows gone mad! (highly improbable).
I don't have a clue what can cause such memory leaks! if I drag the window on desktop for 15 sec the program already uses 300MB memory! IMPRESIVE I may add!

the file with the directX support is attached. It is the one responsible with all the problems!

Elementer
March 10th, 2005, 09:01 AM
Hello,
I think the problem is in main loop, if there is a realtime main loop, check it... Maybe if the program is loading images and generate texture, it can load them at each frame, this cause the 300 MB in some second. I get similiar error years ago :D when I start with graphics library, I generate the texture at each frame without free the graphic card memory from them...
Maybe there is some "new" operator called at each frame that fill the memory without free it, maybe the author forget a "delete" operator, that can happen...

Bye :)

chi_luci
March 10th, 2005, 09:59 AM
is there any directdraw_->DestroySurface() or something to free a surface created with directdraw_->CreateSurface(&dds,&ss, NULL);??? I guess that is the problem, the code is creating surface but never deletes them...

Elementer
March 10th, 2005, 02:17 PM
Hello,
sure, if you create the primary surface with:

CreateSurface(&ddsd, &lpddsprimary, NULL)

you must cleaning up all the ddraw palettes, surfaces etc..., before exit, in that surface example, you must delete the primary surface with this:

lpddsprimary->Release();
lpddsprimary = NULL;

And don't forget to release the ddraw interface, palettes etc..., check the code, can be this the problem ;)

Cheers :)

chi_luci
March 11th, 2005, 12:41 AM
thanks, I will! :wave: