private void btnClick(object sender, EventArgs e)
{
int[] an = new int[8192 * 8192]; // 256 Mb
an = null;
GC.Collect();
}
I understand that GC.Collect doesn't immediately free the memory, but I would expect the memory usage in Task Manager to eventually return to about the same level as before the allocation. It appears to free almost all of it, but stays about 15Mb above the initial level, and then repeated clicks on the button work as expected (+256 Mb followed by -256 Mb).
Of course, if I just allocate a few ints there is no noticeable effect.
And if I change the example to the following then the effect does not occur either:
private void btnClick(object sender, EventArgs e)
{
Image img = new Bitmap(8192, 8192); // 256 Mb
img.Dispose();
GC.Collect();
}
Could anyone explain why 15Mb appears to remain allocated or is it some other internal object
Just curious, thanks.