Debug Assertion Failed! ARGH! NOT AGIAN!! lol

S

SorceCode

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 )
MeshTextures->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!!
 
V

Victor Bazarov

SorceCode said:
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 )
MeshTextures->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.
 
C

Christian Janßen

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 )
MeshTextures->Release();
}
delete[] MeshTextures; // and here


MeshTextures = 0; // and here
}
if( Mesh != NULL )
{
Mesh->Release();
}
}

</snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top