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 texture memory leak #409

Merged
merged 2 commits into from
Apr 22, 2019
Merged

Fix texture memory leak #409

merged 2 commits into from
Apr 22, 2019

Conversation

rferrese
Copy link
Contributor

  • Change MaterialCacheData, MeshCacheData, and TextureCacheData to IDisposable
  • Add ImageCache array to RefCountedCacheData
  • Dont allow replacing arrays in RefCountedCacheData after construction to prevent leaks
  • Prevent recreation of TextureCacheData (leaking references to cloned textures)
  • Add debug asserts to texture reference setting to ensure no leaked references

@rferrese rferrese mentioned this pull request Apr 17, 2019
Copy link
Contributor

@AdamMitchell-ms AdamMitchell-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change. Thanks for fixing that memory leak.

{
TextureDefinition = texture
};
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw in the else case? Or warn or something? Or is it ok to silently do nothing on multiple calls to this function with the same textureIndex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really this entire method needs work. From what it looks like, this will fill in either ImageStreamCache or BufferCache depending on what type it is, but the IF statements dont make that intention clear. Both of these are guarded against multiple calls with the same ID. This also new's TextureCacheData, but that wasnt guarded (which was causing duplicate textures to be created). I'm not entirely sure why this function gets called multiple times, but subsequent calls with the same ID do in fact intend to populate with the same values.

As for your comment, this frequently gets called multiple times with the same ID, so a warning would probably not be the right thing to do in this case. If we rewrote this so that it only got called once per texture, I would be all for it. (similar to the debug asserts I added elsewhere)

@CLAassistant
Copy link

CLAassistant commented Apr 22, 2019

CLA assistant check
All committers have signed the CLA.

@sbtron sbtron merged commit b62aeed into KhronosGroup:master Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants