using System; public class test { public static void Main(){ int[] starts = new int[6] {100,100,100,100,100,200}; foreach (int start in starts){ int limit=0; try{ for (int i=start; i<99999; i++){ byte[] b = new byte[i*1024*1024]; limit = i; } } catch{ Console.WriteLine("started at {0}, got to {1}", start, limit); } } } } started at 100, got to 103 started at 100, got to 102 started at 100, got to 101 started at 100, got to 101 started at 100, got to 101 started at 200, got to 0