【问题标题】:Monotouch and Sqlite errorMonotouch 和 Sqlite 错误
【发布时间】:2011-08-17 14:34:51
【问题描述】:

喂,

有时,我的应用程序会因此消息而崩溃。

Mprotect failed at 0x4f2f000 (length 12288) with errno 12
Stacktrace:

at Mono.Data.Sqlite.SqliteConvert.UTF8ToString (intptr,int) <0x000af>
at Mono.Data.Sqlite.SQLite3.GetText (Mono.Data.Sqlite.SqliteStatement,int) <0x00037>
at Mono.Data.Sqlite.SQLite3.GetValue (Mono.Data.Sqlite.SqliteStatement,int,Mono.Data.Sqlite.SQLiteType) <0x0047b>
at Mono.Data.Sqlite.SqliteDataReader.GetValue (int) <0x0009f>
at Mono.Data.Sqlite.SqliteDataReader.GetValues (object[]) <0x00057>
at TestLibertatea2.LocalDb.Query (string,Mono.Data.Sqlite.SqliteParameter[]) [0x0008c] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:68
at TestLibertatea2.LocalDb.QueryAsList (string,string,Mono.Data.Sqlite.SqliteParameter[]) [0x00006] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:85
at TestLibertatea2.LocalDb.QueryAsList (string,string) [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/Database/LocalDb.cs:79
at TestLibertatea2.DbArticol.GetDbList (string) [0x00006] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Backend/DbArticol.cs:37
at TestLibertatea2.HomePage.loadData () [0x00048] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Controllers/HomePage.cs:105
at TestLibertatea2.HomePage.<ViewDidAppear>m__5 () [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Controllers/HomePage.cs:76
at MonoTouch.Foundation.NSActionDispatcher.Apply () <0x0002b>
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) <0x000cf>
at MonoTouch.UIKit.UIApplication.Main (string[]) <0x00023>
at TestLibertatea2.Application.Main (string[]) [0x00000] in /Users/admin/Projects/TestLibertatea2/TestLibertatea2/Main.cs:17
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

本机堆栈跟踪:

0   TestLibertatea2                     0x005bc51c mono_handle_native_sigsegv + 412
1   TestLibertatea2                     0x005e3708 sigabrt_signal_handler + 148
2   libsystem_c.dylib                   0x36aeb72f _sigtramp + 42
3   libsystem_c.dylib                   0x36ae03bb pthread_kill + 58
4   libsystem_c.dylib                   0x36ad8bff abort + 78
5   TestLibertatea2                     0x0070f044 GC_remap + 200
6   TestLibertatea2                     0x00702a28 GC_allochblk_nth + 1536
7   TestLibertatea2                     0x007023d8 GC_allochblk + 96
8   TestLibertatea2                     0x00708d0c GC_alloc_large + 92
9   TestLibertatea2                     0x007093b0 GC_generic_malloc + 324
10  TestLibertatea2                     0x00709690 GC_malloc_atomic + 332
11  TestLibertatea2                     0x00695ab0 mono_object_allocate_ptrfree + 64
12  TestLibertatea2                     0x00695c1c mono_array_new_specific + 148
13  TestLibertatea2                     0x0050f34c wrapper_managed_to_native_object___icall_wrapper_mono_array_new_specific_intptr_int + 68
14  TestLibertatea2                     0x00349e30 Mono_Data_Sqlite_SQLite3_GetText_Mono_Data_Sqlite_SqliteStatement_int + 56
15  TestLibertatea2                     0x0034ac10 Mono_Data_Sqlite_SQLite3_GetValue_Mono_Data_Sqlite_SqliteStatement_int_Mono_Data_Sqlite_SQLiteType + 1148
16  TestLibertatea2                     0x00361f90 Mono_Data_Sqlite_SqliteDataReader_GetValue_int + 160
17  TestLibertatea2                     0x00361ff4 Mono_Data_Sqlite_SqliteDataReader_GetValues_object__ + 88
18  TestLibertatea2                     0x001a01e8 TestLibertatea2_LocalDb_Query_string_Mono_Data_Sqlite_SqliteParameter__ + 1288
19  TestLibertatea2                     0x001a0704 TestLibertatea2_LocalDb_QueryAsList_string_string_Mono_Data_Sqlite_SqliteParameter__ + 256
20  TestLibertatea2                     0x001a05b8 TestLibertatea2_LocalDb_QueryAsList_string_string + 200
21  TestLibertatea2                     0x001bca90 TestLibertatea2_DbArticol_GetDbList_string + 304
22  TestLibertatea2                     0x0018b494 TestLibertatea2_HomePage_loadData + 516
23  TestLibertatea2                     0x0018cdc8 TestLibertatea2_HomePage__ViewDidAppearm__5 + 128
24  TestLibertatea2                     0x0005f3bc MonoTouch_Foundation_NSActionDispatcher_Apply + 44
25  TestLibertatea2                     0x0050a498 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
26  TestLibertatea2                     0x005a2064 mono_jit_runtime_invoke + 2800
27  TestLibertatea2                     0x00690d38 mono_runtime_invoke + 140
28  TestLibertatea2                     0x00716928 monotouch_trampoline + 2840
29  Foundation                          0x35dca7cd __NSFireTimer + 136
30  CoreFoundation                      0x33538a47 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
31  CoreFoundation                      0x3353aecb __CFRunLoopDoTimer + 850
32  CoreFoundation                      0x3353b845 __CFRunLoopRun + 1088
33  CoreFoundation                      0x334cbec3 CFRunLoopRunSpecific + 230
34  CoreFoundation                      0x334cbdcb CFRunLoopRunInMode + 58
35  GraphicsServices                    0x3639641f GSEventRunModal + 114
36  GraphicsServices                    0x363964cb GSEventRun + 62
37  UIKit                               0x330e8d69 -[UIApplication _run] + 404
38  UIKit                               0x330e6807 UIApplicationMain + 670
39  TestLibertatea2                     0x0008c6fc wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
40  TestLibertatea2                     0x0006af20 MonoTouch_UIKit_UIApplication_Main_string__ + 36
41  TestLibertatea2                     0x001847c8 TestLibertatea2_Application_Main_string__ + 128
42  TestLibertatea2                     0x0050a498 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
43  TestLibertatea2                     0x005a2064 mono_jit_runtime_invoke + 2800
44  TestLibertatea2                     0x00690d38 mono_runtime_invoke + 140
45  TestLibertatea2                     0x00693ce8 mono_runtime_exec_main + 784
46  TestLibertatea2                     0x00692d4c mono_runtime_run_main + 1048
47  TestLibertatea2                     0x005a9814 mono_jit_exec + 216
48  TestLibertatea2                     0x0059c620 main + 3616
49  TestLibertatea2                     0x000024a0 start + 52

来自 gdb 的调试信息:

【问题讨论】:

    标签: sqlite xamarin.ios


    【解决方案1】:

    您的内存不足。

     mmap errno 12 Cannot Allocate Memory
    

    查看 Explanation of MProtect Errno 12 (ENOMEM)iPhone application crashes with Mprotect failed error (MonoTouch) 以了解一些潜在的解决方法(例如尽可能使用 IDisposable)。

    【讨论】:

    • 我该如何测试我的记忆力?我在导航控制器 NSTimer.CreateRepeatingScheduledTimer( new TimeSpan(0,0,1), delegate { Console.WriteLine( String.Format( "Mem: {0:0,0}", GC.GetTotalMemory(false) ) ); });一切看起来都很好,内存并没有变得异常,并且正在被处理掉。
    • “一个数字,它是托管内存中当前分配的字节数的最佳可用近似值。”。关键字是“近似”和“托管”(堆栈上的最后一次调用,带有 IntPtr,可能表示非托管内存)。参考:msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx 您是否尝试覆盖 ReceiveMemoryWarning(如第二个链接中建议的那样)?
    • 是的,我已经覆盖了 ReceiveMemoryWarning 并且它从未被调用...这很奇怪 - 在模拟器上,当我更改当前 UIViewController 时内存没有增长,但在实际的 ipad 设备上,内存正在增长,并且在其中一个视图更改中出现了崩溃。
    • 我忘了说我使用的是 Mono.Data.Sqlite,而不是 iPad 上的 sqlite-net 库,如果它有什么不同的话......
    【解决方案2】:

    好的,在 monotouch 的最新版本(4.0.5)中,这个问题得到了解决。我的幸运是它及时发布了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多