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

ContentManager uses WeakReference for list #849

Merged
merged 2 commits into from Oct 10, 2012

Conversation

KonajuGames
Copy link
Contributor

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.

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.
@Nezz
Copy link
Member

Nezz commented Oct 8, 2012

Just one small thing:
++i should be --i

If that's fixed, it's ready to pull. Thanks for the fix sly.

@KonajuGames
Copy link
Contributor Author

Gah! And that doesn't show up until you add a second ContentManager. Noob error.

@tomspilman
Copy link
Member

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.

@KonajuGames
Copy link
Contributor Author

That would have the same problem that the list had. The event would be
retaining a reference to the ContentManager, thus not allowing the garbage
collector to free it. The event would be the same as the list we have now,
just hidden away inside an event, and we would have less control over it.

@dellis1972
Copy link
Contributor

is this ok to merge?

@Nezz
Copy link
Member

Nezz commented Oct 9, 2012

Yep

@KonajuGames
Copy link
Contributor Author

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.

dellis1972 added a commit that referenced this pull request Oct 10, 2012
ContentManager uses WeakReference for list
@dellis1972 dellis1972 merged commit 2dc562b into MonoGame:develop3d Oct 10, 2012
alxwest pushed a commit to alxwest/MonoGame that referenced this pull request May 3, 2024
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.

None yet

4 participants