Consider this code:
string value = new string('a', int.MaxValue);
When we run that code OutOfMemoryException occurs.Physical memory limits in Windows 8 is 128 GB.
So why .Net throw OutOfMemoryException
for that code?
Also this code never throw OutOfMemoryException :
List<string> list = new List<string>();
for (int i = 0; i < 100000000000; i++)
{
list.Add(new string('a', 100 ));
}
I run it on 64 bit mode.