I have a question about monotouch app memory limitation.
I tried to stress my iPad memory with a very simple app that allocates 1MB arrays into a list. On each loop I display the number of loop. I notice my app crashing around 130 MB allocation.
My code:
List<byte[]> arrays = new List<byte[]>();
try
{
for (int i = 0; i < 1323; i++)
{
arrays.Add(new byte[1024 * 1024]);
Console.WriteLine("RAM: " + (i + 1) + " Mo");
}
}
catch { }
I don't understand why, on an iPad 3 or iPad 4, my app crashes around 130MB with following message:
Native stacktrace:
0 TestMemory 0x002687f9 mono_handle_native_sigsegv + 244 1 TestMemory 0x00295d75 sigabrt_signal_handler + 112 2 libsystem_c.dylib 0x35a75e93 _sigtramp + 42 3 libsystem_c.dylib 0x35a6c123 pthread_kill + 58 4 libsystem_c.dylib 0x35aa8973 abort + 94 5 TestMemory 0x0026353d GC_expand_hp_inner + 0 6 TestMemory 0x00263637 GC_expand_hp_inner + 250 7 TestMemory 0x00263aed GC_collect_or_expand + 128 8 TestMemory 0x00265d99 GC_alloc_large + 96 9 TestMemory 0x00265fe9 GC_generic_malloc + 180 10 TestMemory 0x00266185 GC_malloc_atomic + 112 11 TestMemory 0x0028c011 mono_array_new_specific + 124 12 TestMemory 0x00172e04 wrapper_managed_to_native_object___icall_wrapper_mono_array_new_specific_intptr_int + 68 13 TestMemory 0x0007305c MonoTouch_UIKit_UIControlEventProxy_Activated + 68 14 TestMemory 0x0016df50 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200 15 TestMemory 0x002314e3 mono_jit_runtime_invoke + 1054 16 TestMemory 0x0028c8c3 mono_runtime_invoke + 90 17 TestMemory 0x0022b6f7 native_to_managed_trampoline_MonoTouch_UIKit_UIControlEventProxy_Activated + 178 18 UIKit 0x3ace40a5 <redacted> + 72 19 UIKit 0x3ace4057 <redacted> + 30 20 UIKit 0x3ace4035 <redacted> + 44 21 UIKit 0x3ace38eb <redacted> + 502 22 UIKit 0x3ace357b <redacted> + 242 23 UIKit 0x3ac0c523 <redacted> + 318 24 UIKit 0x3abf9801 <redacted> + 380 25 UIKit 0x3abf911b <redacted> + 6154 26 GraphicsServices 0x3637c5a3 <redacted> + 590 27 GraphicsServices 0x3637c1d3 <redacted> + 34 28 CoreFoundation 0x38856173 <redacted> + 34 29 CoreFoundation 0x38856117 <redacted> + 138 30 CoreFoundation 0x38854f99 <redacted> + 1384 31 CoreFoundation 0x387c7ebd CFRunLoopRunSpecific + 356 32 CoreFoundation 0x387c7d49 CFRunLoopRunInMode + 104 33 GraphicsServices 0x3637b2eb GSEventRunModal + 74 34 UIKit 0x3ac4d2f9 UIApplicationMain + 1120 35 TestMemory 0x0008b3c4 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240 36 TestMemory 0x00219bf0 TestMemory_Application_Main_string__ + 152 37 TestMemory 0x0016df50 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200 38 TestMemory 0x002314e3 mono_jit_runtime_invoke + 1054 39 TestMemory 0x0028c8c3 mono_runtime_invoke + 90 40 TestMemory 0x0028f3a7 mono_runtime_exec_main + 306 41 TestMemory 0x0029262b mono_runtime_run_main + 482 42 TestMemory 0x00242ecf mono_jit_exec + 94 43 TestMemory 0x002cce3c main + 2220 44 TestMemory 0x00002028 start + 40
You crash because you use up all the memory iOS is willing to give you. This is not a MonoTouch limitation, it's an iOS limitation.
User contributions licensed under CC BY-SA 3.0