Jump to content
  • Advertisement
Sign in to follow this  

Error Memory still allocated DX9

This topic is 3598 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

iv made a start on game programming in directX and its going allright everythings working but when i end the game im getting Direct3D9: (ERROR) :Memory still allocated! Alloc count = 2451 Direct3D9: (ERROR) :Current Process (pid) = 000000a8 Direct3D9: (ERROR) :Memory Address: 023007f4 lAllocID=1 dwSize=00004bc4, ReturnAddr=721899aa (pid=000000a8) the longer it runs for the more the alloc count is i have released my D3D (LPDIRECT3D9) and my d3dDev (LPDIRECT3DDEVICE9) the only other things related to directX in there are locals for loading a sprite and displaying it and they are done in functions my load and draw sprite are below
IDirect3DSurface9 *LoadSprite(char *File) {
	D3DXIMAGE_INFO image;
	IDirect3DSurface9 *Surface = NULL;
	if (FAILED(D3DXGetImageInfoFromFile(File, &image))) {
		return NULL;
	}

	if (FAILED(d3dDev->CreateOffscreenPlainSurface(image.Width, image.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &Surface,
		NULL))) {
		return NULL;
	}
	
	if (FAILED(D3DXLoadSurfaceFromFile(Surface, NULL, NULL, File, NULL, D3DX_DEFAULT, 0, NULL))) {
		return NULL;
	}
	return Surface;
}


void DrawSprite(IDirect3DSurface9 *Sprite, RECT Src, int Width, int Height, int X, int Y) {
	IDirect3DSurface9 *BackBuffer = NULL;
	d3dDev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);
	RECT Dest;
	Dest.top = Y;
	Dest.left = X;
	Dest.bottom = Y + Height;
	Dest.right = X + Width;
	d3dDev->StretchRect(Sprite, &Src, BackBuffer, &Dest, D3DTEXF_NONE);
	BackBuffer = NULL;
}
i hope i have given all i need to help you help me

Share this post


Link to post
Share on other sites
Advertisement
From the documentation to GetBackBuffer():
Quote:
Calling this method will increase the internal reference count on the IDirect3DSurface9 interface. Failure to call IUnknown::Release when finished using this IDirect3DSurface9 interface results in a memory leak.


D3D functions that return interfaces usually also increase reference counts.

Share this post


Link to post
Share on other sites
thanks that was a lot quicker then expected i released the back buffer and i made the surface one global so i can release it with my other 2 releases and it works but i still get the error because i didnt release the one for my player sprite BUT when i try and release the player sprite it causes the original surface from the function to give a access violation when i call the clean up i dont see how releaseing the player sprite can cause that but im sure im missing somthing simple again

[Edited by - W4R1SH3R3 on July 13, 2008 9:43:22 AM]

Share this post


Link to post
Share on other sites
Run the DirectX control panel (dxcpl.exe) and there is a debugging option called "Break on AllocID". Put in the AllocID and it will break when it creates the object and show you which object your not releasing before exit.

Share this post


Link to post
Share on other sites
Ok my access violation error that i said i started getting in my other post some how fixed its self so now im error free and HeadKaze thanks for telling me about that option to in the dxcpl it will come in usfull for the tired coding sessions :P

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!