crash [solved]

Started by
6 comments, last by Axiverse 19 years, 5 months ago
ahh! my prgram crashes... i have a wrapper class over DX, and in the destructor of that wrapper class, all resources (device, vb) are released, but after everything is released, and before it executes the next statement outside of the destructor it crashes... i think this is due to releasing of resources because if I don't call the release on either the device or the vb, it doesn't crash... since it's bad to leave resources unreleased i want to fix this now... any ideas? [Edited by - Axiverse on November 2, 2004 11:36:42 AM]
Advertisement
Quote:Original post by Axiverse
ahh! my prgram crashes...

i have a wrapper class over DX, and in the destructor of that wrapper class, all resources (device, vb) are released, but after everything is released, and before it executes the next statement outside of the destructor it crashes...

Perhaps you are using some wrapper's fucntions or variables after they are gone?

Quote:
i think this is due to releasing of resources because if I don't call the release on either the device or the vb, it doesn't crash... since it's bad to leave resources unreleased i want to fix this now...

any ideas?


check if all your code looks as follows:

init Ainit B...release Brelease A


Sorry, I don't know any debugger for VB :(
vb = vertexbuffer...

and it's not used after it's released... i don;t think...

and it's in c++, DX 9b debug
Seems like you may be trying to release already feed memory… depending on the structure of your code it could be that the destructor/release function is being called twice.

Firstly, be sure that all device/buffer pointers are initialized to NULL inside your class constructor:

IDirect3DDevice9 * g_pDevice = NULL;


Be sure that you check to be sure a pointer is valid before you try to release it. AND (I suspect this is your problem) set the pointer to NULL after releasing to prevent errors if the destructor is called twice:

If(g_pDevice){g_pDevice->Release();g_pDevice = NULL;}


Hope this helps,
Jackson Allan
Alot of people just create a macro for that...

#define SAFE_RELEASE(x) if(x){x->Release(); x = NULL;}
--------------------C++ Home - Check it out!Lol... - Amazing video
no luck...

at the end of my destructor, it shows a messagebox, so there is no error in the destructor, but the next line outside the destructor ( after the delete statement ) is never called...
hmmm... now i don't know what the problem is...

there are three objects... one is my wrapper, one is the d3d device, and a vertex buffer... my wrapper is destoryed with delete, and the other two release...

now, if only two are destroyed, there is no problem, but if all three are, the CRASH!!! the think that confuses me that not destroying any one of the objects makes it not crash...
i'm sorry...

you guys were right...

it happened to be that a wrapper within a wrapper also deleted the device... and i overlooked it...

and i even forgot it was there...

there are too many wrappers XD but that's what i get for trying to make a api independent framework ( even though it's based on dx right now XD )

This topic is closed to new replies.

Advertisement