So, I've got this awesome program that is very useful:
static void Main(string[] args)
{
new Dictionary<int,int>(10000000);
while (true)
{
System.Threading.Thread.Sleep(1000);
}
}
This doesn't even produce any warnings from the compiler, which is surprising.
Running this allocates a chunk of memory. If I run several copies, I'll eventually get to a point where I can't start any more because I've run out of memory.
- Why doesn't the garbage collector ever clean up the memory, instead letting the system get into a state where there is not enough memory for new processes?
- Heck, why isn't the memory allocation optimized out? It can never be referenced by anything ever!
So what's going on here?