-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
ContentManager uses WeakReference for list #849
ContentManager uses WeakReference for list #849
Conversation
Change ContentManager's internal list of content managers to a list of WeakReference so content managers can be freed by game code releasing all references to them. Fixes issue MonoGame#848.
Just one small thing: If that's fixed, it's ready to pull. Thanks for the fix sly. |
Gah! And that doesn't show up until you add a second ContentManager. Noob error. |
Possibly this would be a bigger change than we want to do right now, but i'll mention it anyway. We should consider dumping the list of content managers.... instead have the ContentManager register with a "static event ReloadGraphicsContent" on construction and remove itself on disposal/finalization. Would not require any weak references or manual looping thru content managers. |
That would have the same problem that the list had. The event would be |
is this ok to merge? |
Yep |
If it works for Nezz's case where he is removing all references to the ContentManager and the garbage collector is freeing the object correctly, then it is all good. |
ContentManager uses WeakReference for list
Change ContentManager's internal list of content managers to a list of WeakReference so content managers can be freed by game code releasing all references to them. Fixes issue #848.