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

Added selective ContentManager asset unloading #6663

Open
wants to merge 1 commit into
base: develop
from

Conversation

Projects
None yet
4 participants
@tdeeb
Copy link
Contributor

commented Feb 16, 2019

This PR adds two new methods to ContentManager:

  1. UnloadAsset - Unloads a single asset and disposes it if it's disposable
  2. UnloadAssets - Takes in an IList<string> of asset names to unload and disposes the associated assets if they're disposable

Relevant issue: #6164

@nkast

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2019

@tdeeb

-What would happen if I unload a Model ?
(will it free up the resources? VertexBuffers,Effects, and textures?)

-What would happen if I continuously unload and reload the same Model?
(when the player navigates back and forth the menus for example)

(the same applies to any custom assets that isn't disposable but contains native resources, not just Models)

@tdeeb

This comment has been minimized.

Copy link
Contributor Author

commented Feb 16, 2019

-I'm not the most knowledgeable about models, but I just went through the code and it doesn't look to unload any of those. The currently existing Unload method won't do so either. The user has to free these up manually.

-It would keep creating new Effects, etc. and likely cause memory leaks, should the user fail to manually free up the additional resources the model uses.

-If custom assets contain native resources, they should be implementing IDisposable. See here. Failure to do so gives them no standardized mechanism of releasing them, and they'll have to find another way to properly free up everything, either by manually doing it or overriding these methods to contain code specific to certain types of assets.

@Jjagg

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2019

The currently existing Unload method won't do so either. The user has to free these up manually.

No, the content manager used to load the model will contain all disposable resources the model requires like effects and textures, so they're disposed when the content manager is unloaded.

If custom assets contain native resources, they should be implementing IDisposable

They should after this change, but just like Model, assets that can only be created through the content pipeline could depend on the unloading behavior instead of implementing IDisposable.

@mrhelmut

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2019

I think that unloading models should only unload the vertex buffer to give the control to the developer to handle the effect/texture on their own if need be (thinking about shared effect/texture). Which is what this PR does.

@tdeeb

This comment has been minimized.

Copy link
Contributor Author

commented Mar 2, 2019

What modifications need to be made to get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.