question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

D3D11CreateDevice with context Memory Leak (VRAM)

See original GitHub issue

Hi @amerkoleci and happy new year!

I come up with this one that you might want to check:-

public void NoMemoryLeak()
{
	D3D11.D3D11CreateDevice(null, DriverType.Hardware, DeviceCreationFlags.BgraSupport, new FeatureLevel[] { FeatureLevel.Level_11_0 }, out ID3D11Device device);
	System.Threading.Thread.Sleep(500);
	device.Dispose();
}

public void MemoryLeak()
{
	D3D11.D3D11CreateDevice(null, DriverType.Hardware, DeviceCreationFlags.BgraSupport, new FeatureLevel[] { FeatureLevel.Level_11_0 }, out ID3D11Device device, out _, out ID3D11DeviceContext context);
	System.Threading.Thread.Sleep(500);
	context.ClearState();
	context.Flush();
	context.Dispose();
	device.Dispose();
}

And did some test with task manager and the dedicated GPU memory column in details Tab:

Task.Run(() =>
{
    while (true)
        MemoryLeak();
});

Update: I solved my memory leak issue but I think it was not related it with the above. I just used FlipDiscard instead of Discard. Might FFmpeg messed with my Device not sure yet.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
amerkolecicommented, Jan 19, 2022

Can you try with 2.1.1-beta5 release?

0reactions
SuRGeoNixcommented, Jan 19, 2022

Looks ok now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak in my DX11 program
Notice you are talking about RAM not VRAM, so somehow I doubt it's the actual DX object that leaks. Because buffers are stored...
Read more >
Why is there a video memory leak when using ...
Now I find that every time B calls CopyResource to copy the shared texture to the local, the video memory will keep increasing....
Read more >
Why does this DirectX call leak memory?
I've been fighting a memory leak in my software, ... HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, pLevels, ...
Read more >
Disposing Device seems to leak some memory · Issue #982
Consider code like this: for (int i = 0; i < 1_000_000; i++) { Device d = new Device(SharpDX.Direct3D.DriverType.Hardware); d.
Read more >
How can I chase down VRAM & GTT memory leaks?
Probably not. Most OpenGL resources (framebuffers, vertex buffer objects, textures &c.) are controlled by host code (i.e. your C++ code), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found