is D3DDevice Releasing Automatically ?
hello everyone,
i always see following code in examples
if (g_pd3dDevice <> nil) then
{$IFDEF TMT}
g_pd3dDevice.Release;
{$ELSE}
g_pd3dDevice:= nil;
{$ENDIF}
is D3DDevice Releasing Automatically
What language is that? Pascal?
No, the device does not release itself automatically, you must call it's Release() method to free the resources associated with it. The reason a lot of code tends to check that the device isn't null/nill at shutdown is that it's possible the shutdown code will be called more than once (E.g. if an error occurs, and then again at application exit). That would cause the device to be released, but then it would be referenced again by the Release() call, which would cause an access violation and a lovely Windows "The application has encountered an error" message box...
No, the device does not release itself automatically, you must call it's Release() method to free the resources associated with it. The reason a lot of code tends to check that the device isn't null/nill at shutdown is that it's possible the shutdown code will be called more than once (E.g. if an error occurs, and then again at application exit). That would cause the device to be released, but then it would be referenced again by the Release() call, which would cause an access violation and a lovely Windows "The application has encountered an error" message box...
thanks Evil Steve
what ever is that "TMT" flag, it doesnt work in my pascal code so the second code works "g_pd3dDevice:= nil;"
my COM object (g_pd3dDevice) has a "_Release" command not a "Release".
that two command are different?
may be g_pd3dDevice does release itself when the hwnd(window) destroying
any way i'm a finicky person so its make me restless
what ever is that "TMT" flag, it doesnt work in my pascal code so the second code works "g_pd3dDevice:= nil;"
my COM object (g_pd3dDevice) has a "_Release" command not a "Release".
that two command are different?
may be g_pd3dDevice does release itself when the hwnd(window) destroying
any way i'm a finicky person so its make me restless
That looks like some sort of preprocessor stuff in Pascal. If your device has a _Release() method, you should probably call that. I'm not realyl sure about Pascal though.
You should get some sort of debug output from D3D, and any memory leaks from un-Release()d interfaces will be shown there.
You should get some sort of debug output from D3D, and any memory leaks from un-Release()d interfaces will be shown there.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement