Sign in to follow this  
Magoo2005

menory leaks with d3d

Recommended Posts

Magoo2005    122
hi i am having problems with memory leaks with d3d9 every time i exit my program i get the following junk Direct3D9: (ERROR) : [3] : Address 010FE215 Direct3D9: (ERROR) : [4] : Address 01145EF8 Direct3D9: (ERROR) : [5] : Address 011489FD i have currently disabled all rendering and am only using swapchains atm if someone could find a reason for this in the following code it would be a great help
void DisplayNorm(float &timeDelta)
{
   D3DXMATRIX matTranslation;
   if(!freeCamera)
      camera.setViewPoint(game.GetFollowCar()->getFacingDirection1(),game.GetFollowCar()->getPosition1(),Device);
      else
      camera.setViewPoint(Device);

   if(Device)
   {
    LPDIRECT3DSURFACE9 pBackBuffer = NULL;

	chain1->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
	Device->SetRenderTarget(0, pBackBuffer);
   Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
		Device->BeginScene();
      game.Render(Device,timeDelta,world,freeCamera);
      Device->EndScene();
      chain1->Present(NULL, NULL, g_hwnd1, NULL, 0);
   pBackBuffer->Release();
   }
}

Share this post


Link to post
Share on other sites
sirob    1181
The first line of the error sequence for the memory that was still allocated contains an "AllocID". Use that, and enter it to the "Break on AllocID" field in the DirectX App in the Control Panel. This will make DX stop when the object that you are not releasing is created -- showing you what it is.

Hope this helps.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
<shameless-plug>
I just updated my journal with an entry about using smart pointers and Direct3D. Using smart pointers would quite probably solve your problem [wink]
</shameless-plug>

Are you definitely sure that pBackBuffer->Release(); is called every frame? How about all other objects?

You really should be checking the return codes for your functions - you could be missing lots of errors and getting your application into inconsistent states.

hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this