Reputation: 3672
In this C# example, will the garbage collector dispose of hugeString
after TestClass
is instantiated?
Furthermore, would uncommenting the line hugeString = null
help garbage collection at all?
public sealed class TestClass
{
public TestClass()
{
var hugeString = new string('0', 100000000);
var length = hugeString.Length;
GetLength = () => length;
// hugeString = null; // do I need to do this?
}
public readonly Func<int> GetLength;
}
Upvotes: 0
Views: 82