I know that with C# garbage collection happens automatically. But I've read that it only happens when memory is needed. Therefore, your game might still be taking up a larger memory footprint than necessary a lot of the time.
So, I've read that one way to have some control over garbage collection is to wrap some code in a "[using][1]" block. Then whatever temporary variable or object is in that "using" statement will have its memory immediately released at the end of the block, rather than "at some time in the future".
I've shipped several games now, but I've never used the "using" keyword in this way. I'm wondering now if I should try to be more diligent about doing that. My instinct says that it doesn't matter all that much and just makes the code look messier. I'm wondering what others think.
[1]: http://msdn.microsoft.com/en-us/library/yh598w02%28v=vs.80%29.aspx
↧