Jump to content
  • Advertisement
Sign in to follow this  

Corruption of the heap?

This topic is 4117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Good evening. I am having some hard to solve problems in my D3D application. My application merely renders a couple of default DX objects (teapot, box, torus, sphere and cylinder) to the scene, and I am using my HLSL shader to put some lighting to the scene. However, when I am running a debug build without debuging in Visual Express ed. 2005, it works, everything looks correct, but it crashes when I close it and I recieve a classic windows XP "Send error report" message. If I however run it with debug, yet no breakpoints, it is interrupted at the start of the rendering loop by a windows generated breakpoint and I recieve this message: "Windows has triggered a breakpoint in Direct3D.exe. This may be due to a corruption of the heap, and indicates a bug in Direct3D.exe or any of the DLLs it has loaded. The output window may have more diagnostic information" And the debug output log is saying: "HEAP[Direct3D.exe]: HEAP: Free Heap block 1207ba8 modified at 1207bb8 after it was freed Windows has triggered a breakpoint in Direct3D.exe." If I try building and running a release mode it crashes already in the beginning. I am pretty sure where the error is, but however I just don't know really how to solve it since it is the first time I use the CloneMesh() function to change the vertex declaration to my own. Here's the source of the function where I use this function call.
[Source] void c_3DModel::ChangeToCustomVertexDeclaration(IDirect3DDevice9 *p_Device)
	// Look up some stuff about the meshes before changing declaration.

	D3DVERTEXELEMENT9 Elements[] = 

	LPD3DXMESH p_TempModel = NULL;//(LPD3DXMESH)malloc(sizeof(*p_Model));

	// Clones the DX generated model and sets our custom vertex declaration to it.
	// NOTE: Position and Normals will be correct, but the default model has no 
	//		 UV coords set so have to do that manualy.
	//p_Model->CloneMesh(p_Model->GetOptions(), Elements, p_Device, &p_Model);
	p_Model->CloneMesh(p_Model->GetOptions(), Elements, p_Device, &p_TempModel);

	// Trying to avoid memory leaks.
	p_Model = NULL;

	p_Model = p_TempModel;
} [/Source]
The CloneMesh() function I have commented out I have tried as well, but however it is creating 14 memory leaks in my aplication. However, perhaps this version does so too, I don't know since I never can get to the end of the application in debug runs because of that windows generated break point due to heap corruption. All I can find about CloneMesh is MSDNs explanation of it, but they have no examples of how to use it, and I have failed to find any examples that is similar to my problem. I'd apreciate if anyone could take a look at it and tell me what more I have to do or do different to avoid leaks and successfully convert to my own vertex format. Perhaps there is more to my problem than this function, but since I can't get any futher in my code in debug mode when I do this convertion I have to start solving that. And also, if I don't convert the vertex format it works and without any memory leaks. So I am certain I do the CloneMesh wrong in one or another way. Have tried to use PIX too since that was recommended to me in my last post, but I am very new to that so it hasn't helped me any with this. Thanks for reading and for all help I've recieved so far =) Oh and if anyone want to look at more of the source I'd gladly post it, just don't wanna make it too long if this is all that is needed to solve it. / Bertil

Share this post

Link to post
Share on other sites
Actualy, I managed to locate the problem just now! So no need to trouble yourselves! You who already read it, thank you for your time. Seemed like I was wrong, the CloneMesh() seems to work, the problem was when I was setting UV coordinates. :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!