[info-performer] Solution memory leak caused by GetDC()

Date view Thread view Subject view Author view

From: Peter Krueger (pkrueger++at++appss.de)
Date: 04/23/2004 05:33:59


Hello Performer/WIN32 developers at SGI!
I've tried to find out why Performer has this memory leak problem with
GetDC(). So I looked into the GTK-GlExt code to see what happens there and
why GTK doesn't have this problem. I think I've found some relevant code.

The flag need_release_dc is determined in the initialization phase of the
GtkGlWidget. I think this could be placed in setWSWindow():
BOOLEAN need_release_dc;
// find out whether it is a private DC
DWORD wndclass_style = GetClassLong (hwnd, GCL_STYLE);
if (wndclass_style & CS_OWNDC) need_release_dc = FALSE;
else need_release_dc = TRUE;

When OpenGL shall be enabled the following is called and the hdc is stored
for the finalization phase:
hdc = GetDC (hwnd);
wglMakeCurrent(hdc, hglrc);

When all OpenGL calls are done for this frame the following is called:
SwapBuffers (hdc);
// the hdc is released now if necessary
if (need_release_dc) ReleaseDC (hwnd, hdc);

I hope this will help you to improve the Windows port of Performer and
make it work whether the window has its own HDC or not.

Regards,
                     Peter

-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH Sandtorstr. 23 D-39106 Magdeburg Germany

Phone: +49-(0)391-54486-19388 Fax: +49-(0)391-54486-19222 email: krueger++at++appss.de URL: http://www.appss.de/

Managing Director: Uwe Hess, Dietmar Schäfer Register: HRB12386, AG Magdeburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ====================================================================


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Apr 23 2004 - 05:37:15 PDT