Sign in to follow this  
Tordin

DX11 [DX11] Memory leeks that i cant get ridoff

Recommended Posts

Tordin    625
Hello!

I noticed that i got memory leaks from the dx debug device.
i have been on this for ever trying to solve it but how hard i try i still get the same ones...

Example :

D3D11: WARNING: Live Device: Name="unnamed", Addr=0x00286EE8, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x00288E4C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x002889EC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x002887B4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x0028858C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x00288404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x0028CDA4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x0228006C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x00286EE8

When i google the warnings i only get post about ppl who havent released it right, but i are more than sure that i have!

Any clues Internet?

Share this post


Link to post
Share on other sites
Magmatwister    109
[quote name='Tordin' timestamp='1312591384' post='4845293']
Hello!

I noticed that i got memory leaks from the dx debug device.
i have been on this for ever trying to solve it but how hard i try i still get the same ones...

Example :

D3D11: WARNING: Live Device: Name="unnamed", Addr=0x00286EE8, ExtRef=1 [ STATE_CREATION WARNING #2097297: LIVE_DEVICE ]
D3D11: WARNING: Live Texture2D: Name="unnamed", Addr=0x00288E4C, ExtRef=0, IntRef=0 [ STATE_CREATION WARNING #2097235: LIVE_TEXTURE2D ]
D3D11: WARNING: Live Query: Name="unnamed", Addr=0x002889EC, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097280: LIVE_QUERY ]
D3D11: WARNING: Live Sampler: Name="unnamed", Addr=0x002887B4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097268: LIVE_SAMPLER ]
D3D11: WARNING: Live RasterizerState: Name="unnamed", Addr=0x0028858C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097277: LIVE_RASTERIZERSTATE ]
D3D11: WARNING: Live DepthStencilState: Name="unnamed", Addr=0x00288404, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097274: LIVE_DEPTHSTENCILSTATE ]
D3D11: WARNING: Live BlendState: Name="unnamed", Addr=0x0028CDA4, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097271: LIVE_BLENDSTATE ]
D3D11: WARNING: Live Context: Name="unnamed", Addr=0x0228006C, ExtRef=0, IntRef=1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT ]
D3D11: WARNING: Live Device Child Summary: Device Addr=0x00286EE8

When i google the warnings i only get post about ppl who havent released it right, but i are more than sure that i have!

Any clues Internet?
[/quote]

Trust me, you haven't. I'm currently working on a planet renderer and everytime I get memory leaks, I find that I, indeed had some obscure situation where they weren't released. Try slowly commenting out code sections until you get a clean exit.

Share this post


Link to post
Share on other sites
Jason Z    6434
The list shows that you have an outstanding device reference. What happens if you do a double release on your device before exiting the program? You can also check the status of the objects with PIX to see if there is something that you hadn't considered before...

Share this post


Link to post
Share on other sites
bubu LV    1436
Try setting debug names for all the Direct3D objects you create - that includes device, textures, buffers, states, etc... Then this debug display will include name of object that is alive (instead of name="unamed"). For textures, for example, use name of file you load. For buffers use name of mesh/model you are storing there, and so on.

Do it like this: http://msdn.microsoft.com/en-us/library/ff476881.aspx

Then you will exactly which objects are alive.

Share this post


Link to post
Share on other sites
Tordin    625
[quote name='Jason Z' timestamp='1312614076' post='4845347']
The list shows that you have an outstanding device reference. What happens if you do a double release on your device before exiting the program? You can also check the status of the objects with PIX to see if there is something that you hadn't considered before...
[/quote]


Nice, that got rid of everything for me!

How come i have to do it twice?


Share this post


Link to post
Share on other sites
bubu LV    1436
Are you calling on some object like buffer, or shader GetDevice method? GetDevice method increments reference count by one, so you should also add Release call after you process device returned by GetDevice method.

Share this post


Link to post
Share on other sites
w00key    100
As MartinsM says everytime you use GetDevice or GetBuffer it actually increments a reference counter.

This means if you don't release after you've done these functions it'll warn that some objects and anything linked to it are still active.

Calling release at these points decreases the ref counter and the object is still alive.

For example

[code]ID3D11Texture2D* pBackBuffer = nullptr;
if(FAILED(swapChain_->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( void** )&pBackBuffer ))) //increments ref counter
{
MessageBox( NULL, "Failed to get the back buffer.", "Error", MB_OK );
return false;
}

if(FAILED(device_->CreateRenderTargetView( pBackBuffer, NULL, renderTarget)))
{
MessageBox( NULL, "Failed to create a render target from the back buffer.", "Error creating render target", MB_OK );
return false;
}
pBackBuffer->Release(); // called release to decrease ref counter
[/code]

Aside from this its mostly a case of looking for sampler/blender/rasterizer states that haven't been released.

Share this post


Link to post
Share on other sites
bubu LV    1436
And if you are not comfortable with calling manually Release, then simply use CComPtr (from atlbase.h) everywhere instead of raw ID3D11xyz pointers:
[code]{
CComPtr<ID3D11Texture2D> pBackBuffer;
if(FAILED(swapChain_->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( void** )&pBackBuffer ))) //increments ref counter
{
MessageBox( NULL, "Failed to get the back buffer.", "Error", MB_OK );
return false;
}

if(FAILED(device_->CreateRenderTargetView( pBackBuffer, NULL, renderTarget)))
{
MessageBox( NULL, "Failed to create a render target from the back buffer.", "Error creating render target", MB_OK );
return false;
}
} // no need to call pBackBuffer->Release(), it will be called automatically[/code]

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  

  • Similar Content

    • By isu diss
       I'm trying to code Rayleigh part of Nishita's model (Display Method of the Sky Color Taking into Account Multiple Scattering). I get black screen no colors. Can anyone find the issue for me?
       
      #define InnerRadius 6320000 #define OutterRadius 6420000 #define PI 3.141592653 #define Isteps 20 #define Ksteps 10 static float3 RayleighCoeffs = float3(6.55e-6, 1.73e-5, 2.30e-5); RWTexture2D<float4> SkyColors : register (u0); cbuffer CSCONSTANTBUF : register( b0 ) { float fHeight; float3 vSunDir; } float Density(float Height) { return exp(-Height/8340); } float RaySphereIntersection(float3 RayOrigin, float3 RayDirection, float3 SphereOrigin, float Radius) { float t1, t0; float3 L = SphereOrigin - RayOrigin; float tCA = dot(L, RayDirection); if (tCA < 0) return -1; float lenL = length(L); float D2 = (lenL*lenL) - (tCA*tCA); float Radius2 = (Radius*Radius); if (D2<=Radius2) { float tHC = sqrt(Radius2 - D2); t0 = tCA-tHC; t1 = tCA+tHC; } else return -1; return t1; } float RayleighPhaseFunction(float cosTheta) { return ((3/(16*PI))*(1+cosTheta*cosTheta)); } float OpticalDepth(float3 StartPosition, float3 EndPosition) { float3 Direction = normalize(EndPosition - StartPosition); float RayLength = RaySphereIntersection(StartPosition, Direction, float3(0, 0, 0), OutterRadius); float SampleLength = RayLength / Isteps; float3 tmpPos = StartPosition + 0.5 * SampleLength * Direction; float tmp; for (int i=0; i<Isteps; i++) { tmp += Density(length(tmpPos)-InnerRadius); tmpPos += SampleLength * Direction; } return tmp*SampleLength; } static float fExposure = -2; float3 HDR( float3 LDR) { return 1.0f - exp( fExposure * LDR ); } [numthreads(32, 32, 1)] //disptach 8, 8, 1 it's 256 by 256 image void ComputeSky(uint3 DTID : SV_DispatchThreadID) { float X = ((2 * DTID.x) / 255) - 1; float Y = 1 - ((2 * DTID.y) / 255); float r = sqrt(((X*X)+(Y*Y))); float Theta = r * (PI); float Phi = atan2(Y, X); static float3 Eye = float3(0, 10, 0); float ViewOD = 0, SunOD = 0, tmpDensity = 0; float3 Attenuation = 0, tmp = 0, Irgb = 0; //if (r<=1) { float3 ViewDir = normalize(float3(sin(Theta)*cos(Phi), cos(Theta),sin(Theta)*sin(Phi) )); float ViewRayLength = RaySphereIntersection(Eye, ViewDir, float3(0, 0, 0), OutterRadius); float SampleLength = ViewRayLength / Ksteps; //vSunDir = normalize(vSunDir); float cosTheta = dot(normalize(vSunDir), ViewDir); float3 tmpPos = Eye + 0.5 * SampleLength * ViewDir; for(int k=0; k<Ksteps; k++) { float SunRayLength = RaySphereIntersection(tmpPos, vSunDir, float3(0, 0, 0), OutterRadius); float3 TopAtmosphere = tmpPos + SunRayLength*vSunDir; ViewOD = OpticalDepth(Eye, tmpPos); SunOD = OpticalDepth(tmpPos, TopAtmosphere); tmpDensity = Density(length(tmpPos)-InnerRadius); Attenuation = exp(-RayleighCoeffs*(ViewOD+SunOD)); tmp += tmpDensity*Attenuation; tmpPos += SampleLength * ViewDir; } Irgb = RayleighCoeffs*RayleighPhaseFunction(cosTheta)*tmp*SampleLength; SkyColors[DTID.xy] = float4(Irgb, 1); } }  
    • By amadeus12
      I made my obj parser
      and It also calculate tagent space for normalmap.
      it seems calculation is wrong..
      any good suggestion for this?
      I can't upload my pics so I link my question.
      https://gamedev.stackexchange.com/questions/147199/how-to-debug-calculating-tangent-space
      and I uploaded my code here


      ObjLoader.cpp
      ObjLoader.h
    • By Alessandro Pozzer
      Hi guys, 

      I dont know if this is the right section, but I did not know where to post this. 
      I am implementing a day night cycle on my game engine and I was wondering if there was a nice way to interpolate properly between warm colors, such as orange (sunset) and dark blue (night) color. I am using HSL format.
      Thank  you.
    • By thefoxbard
      I am aiming to learn Windows Forms with the purpose of creating some game-related tools, but since I know absolutely nothing about Windows Forms yet, I wonder:
      Is it possible to render a Direct3D 11 viewport inside a Windows Form Application? I see a lot of game editors that have a region of the window reserved for displaying and manipulating a 3D or 2D scene. That's what I am aiming for.
      Otherwise, would you suggest another library to create a GUI for game-related tools?
       
      EDIT:
      I've found a tutorial here in gamedev that shows a solution:
      Though it's for D3D9, I'm not sure if it would work for D3D11?
       
    • By Cyndanera
      in directx I need to know how would I play the animation in directx rendering frames for each part of the model moving parts - like the bones, how would would that work?
      I'm new to writing a animation player, for a model parser.
      I'm asking so I understand how to do this, I'm new to loading a model and playing\moving the bones to effect the mesh.
  • Popular Now