static void AllocBigMemoryBlock (int pass)
{
const int MB = 1024 * 1024;
byte[] array = null;
long maxmem = 0;
int arraySize = 0;
GC.Collect ();
GC.WaitForPendingFinalizers ();
while (true)
{
try
{
arraySize += 10;
array = new byte[arraySize * MB];
array[arraySize * MB - 1] = 100;
GC.Collect ();
GC.WaitForPendingFinalizers ();
maxmem = GC.GetTotalMemory (true);
Console.Write ("Pass: {0} Array Size (MB): {1:D4} {2:D4}/r", pass, arraySize, Convert.ToInt32 (maxmem / MB));
}
catch (System.OutOfMemoryException)