Say I have the following class that simply allocates an array:
public class ArrayAllocator
{
private int[] _arr;
public int [] Allocate(uint size)
{
_arr = new int[size];
return _arr;
}
}
Which I then use like this:
ArrayAllocator allocator = new ArrayAllocator();
int [] result;
result = allocator.Allocate(10); // create space for 10 ints
result = allocator.Allocate(20); // create space for 20 ints, using the same pointer
Does the GC know that I have finished with the initial 10 ints when I make the next allocation using the same pointer _arr
and free the memory when it runs?
Thanks