By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

Debug Assertion Failed! ARGH! NOT AGIAN!! lol

P: n/a
Hey guys, good old
Debug Assertion Failed!
File: dbgdel.cpp
Line: 47
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)


Rears its ugly head agian!

Ok heres what Im up to..

DirectX 9.0
C++
Nuff said lol

<Snippit>

class w_DXObject
{
public:
LPD3DXMESH Mesh; // Our mesh object in sysmem
D3DMATERIAL9* MeshMaterials; // Materials for our mesh
LPDIRECT3DTEXTURE9* MeshTextures; // Textures for our mesh
DWORD NumMaterials; // Number of mesh materials

// Constructor
w_DXObject()
{
Mesh = NULL;
MeshMaterials = NULL;
MeshTextures = NULL;
NumMaterials = 0L;
}

// DeConstructor
~w_DXObject()
{

}

void DestroyObject();
bool LoadMesh(LPDIRECT3DDEVICE9 Device, char* strFileName );
bool Render(LPDIRECT3DDEVICE9 Device);
};

void w_DXObject::DestroyObject()
{
// FIX ME!! MEMORY LEAK!!
if( MeshMaterials != NULL )
delete[] MeshMaterials; //throws here

if( MeshTextures )
{
for( DWORD i = 0; i < NumMaterials; i++ )
{
if( MeshTextures[i] )
MeshTextures[i]->Release();
}
delete[] MeshTextures; // and here
}
if( Mesh != NULL )
{
Mesh->Release();
}
}

As you can see Im using class ref's of the things I am deleting.
The MS File itself and most of the stuff I have read about this online
show that I should only delete locals. No DLL's are involed in this
prog.
Based on DX9 AppWizard.

Feel free to ask anything else.
Thanks in advance guys!!
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"SorceCode" <so*******@hotmail.com> wrote...
Hey guys, good old
Debug Assertion Failed!
File: dbgdel.cpp
Line: 47
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Rears its ugly head agian!

Ok heres what Im up to..

DirectX 9.0
C++
Nuff said lol

<Snippit>

class w_DXObject
{
public:
LPD3DXMESH Mesh; // Our mesh object in sysmem
D3DMATERIAL9* MeshMaterials; // Materials for our mesh
LPDIRECT3DTEXTURE9* MeshTextures; // Textures for our mesh
DWORD NumMaterials; // Number of mesh materials

// Constructor
w_DXObject()
{
Mesh = NULL;
MeshMaterials = NULL;
MeshTextures = NULL;
NumMaterials = 0L;
}

// DeConstructor
~w_DXObject()
{

}

void DestroyObject();
bool LoadMesh(LPDIRECT3DDEVICE9 Device, char* strFileName );
bool Render(LPDIRECT3DDEVICE9 Device);
};

void w_DXObject::DestroyObject()
{
// FIX ME!! MEMORY LEAK!!
if( MeshMaterials != NULL )
delete[] MeshMaterials; //throws here

if( MeshTextures )
{
for( DWORD i = 0; i < NumMaterials; i++ )
{
if( MeshTextures[i] )
MeshTextures[i]->Release();
}
delete[] MeshTextures; // and here
}
if( Mesh != NULL )
{
Mesh->Release();
}
}

As you can see Im using class ref's of the things I am deleting.
The MS File itself and most of the stuff I have read about this online
show that I should only delete locals. No DLL's are involed in this
prog.
Based on DX9 AppWizard.

Feel free to ask anything else.


Let me ask: aren't OLE objects supposed to delete themselves when
the last handle is released? If so, why are you 'delete'ing them?
You just 'Release' them and be done, no?

Anyway, if you don't know the answer to this question, we don't
either because OLE and stuff like that is off-topic here. Try
comp.os.ms-windows.programmer.win32 or any newsgroup with .ole.
in it.
Thanks in advance guys!!

Jul 22 '05 #2

P: n/a
<snip>
void w_DXObject::DestroyObject()
{
// FIX ME!! MEMORY LEAK!!
if( MeshMaterials != NULL )
delete[] MeshMaterials; //throws here
MeshMaterials = 0; // missing here

if( MeshTextures )
{
for( DWORD i = 0; i < NumMaterials; i++ )
{
if( MeshTextures[i] )
MeshTextures[i]->Release();
}
delete[] MeshTextures; // and here
MeshTextures = 0; // and here
}
if( Mesh != NULL )
{
Mesh->Release();
}
}


</snip>
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.