Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memleak on GraphicsDevce.DirectD3.Begin() #427

Conversation

@ryancheung
Copy link

ryancheung commented Apr 1, 2019

PR Details

Fix memleak on GraphicsDevce.DirectD3.Begin()

GraphicsDevce.DirectD3.Begin() method keep new creating SharpDX.DirectD3D11.Query object after
every frame and created objects do not get freed.

Description

Related Issue

Motivation and Context

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
.Begin() method keep new creating SharpDX.DirectD3D11.Query object after
every frame and created objects do not get freed.
@CLAassistant

This comment has been minimized.

Copy link

CLAassistant commented Apr 1, 2019

CLA assistant check
All committers have signed the CLA.

{
var disjointQueryDiscription = new QueryDescription { Type = SharpDX.Direct3D11.QueryType.TimestampDisjoint };
currentDisjointQuery = new Query(NativeDevice, disjointQueryDiscription);
}

disjointQueries.Enqueue(currentDisjointQuery);
// Try to read back the oldest disjoint query and reuse it. If not ready, create a new one.
if (NativeDeviceContext.GetData(currentDisjointQuery, out QueryDataTimestampDisjoint result))

This comment has been minimized.

Copy link
@xen2

xen2 Apr 1, 2019

Member

Thanks for initial investigation about this memory leak.

Data is supposed to come back asynchronously, typically a few frame later.
As a result, this GetData calls probably always return false if we keep reusing a single one.

This is the reason we need a pool of them. It shouldn't grow much more than 2/3 objects (GPU is behind a few frames, but not much more usually).
Is this the place that keeps allocating regularly?
We need to find out why it keeps allocating them rather than always reusing a pool of 2/3.

This comment has been minimized.

Copy link
@ryancheung

ryancheung Apr 1, 2019

Author

Thanks for engaging in this issue. Could you take a loot at #428?

This memleak was found when I'm trying to fix low performance issue with Xenko.

@xen2

This comment has been minimized.

Copy link
Member

xen2 commented Apr 9, 2019

I investigated and found the root reason.
Will commit a fix for this very shortly.
Closing this PR.

@xen2 xen2 closed this Apr 9, 2019
xen2 added a commit that referenced this pull request Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.