ipad - Monotouch内存限制崩溃

标签 ipad memory xamarin.ios crash

我对单点触控应用内存限制有疑问。

我尝试使用一个非常简单的应用程序来强调我的 iPad 内存,该应用程序将 1MB 数组分配到列表中。在每个循环上,我显示循环数。我注意到我的应用程序在大约 130 MB 分配时崩溃了。

我的代码:

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 { }

我不明白为什么在 iPad 3 或 iPad 4 上,我的应用程序在 130MB 左右崩溃并显示以下消息:

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

最佳答案

你崩溃是因为你用完了 iOS 愿意提供给你的所有内存。这不是 MonoTouch 限制,而是 iOS 限制。

关于ipad - Monotouch内存限制崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17315662/

相关文章:

ios - UITableView 删除按钮没有出现

ipad - 无法在 ipad safari 上播放 html5 音频

go - Golang中的0x1是什么意思?

Xamarin.UITests ApkFile 或 InstalledApp 尚未在 VS 中配置

javascript - 如何在 iPad Safari 浏览器的 HTML5 代码中使用 Javascript 以编程方式清除 session 和 cookie 值

javascript - 如何正确使用媒体查询(css)?

r - 在 R 中逐行绑定(bind) data.frames 而不创建副本

iphone - iOS iPhone CGImage 内存问题

c# - 设备锁定或 sleep 时音频暂停 MonoTouch

c# - 从 XML 数据写入 SQLite 数据库