Android应用程序中的JNI表溢出

时间:2017-03-23 12:42:04

标签: java android memory-leaks java-native-interface out-of-memory

我有一个Android应用程序在几个屏幕之间来回传递,这些屏幕被组织为使用viewPager进行滚动的活动的片段。

当在这些屏幕中移动太多时,应用程序会崩溃 JNI ERROR(app bug):本地参考表溢出(max = 512)

这是stacktrace:

03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127] JNI ERROR (app bug): local reference table overflow (max=512)
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127] local reference table dump:
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]   Last 10 entries (of 512):
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]       511: 0x144abc00 long[] (6 elements)
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]       510: 0x144abbc0 long[] (6 elements)
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]       509: 0x144abb80 long[] (6 elements)
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]       508: 0x144abb40 long[] (6 elements)
03-23 13:25:56.781 8120-8506/com.example.debug A/art: art/runtime/indirect_reference_table.cc:127]       507: 0x144abb00 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       506: 0x144abac0 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       505: 0x144aba80 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       504: 0x144aba40 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       503: 0x144aba00 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       502: 0x144ab9c0 long[] (6 elements)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]   Summary:
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]       511 of long[] (6 elements) (511 unique instances)
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127]         1 of java.lang.Thread
03-23 13:25:56.781 8120-8506/de.everskill.everskill.debug A/art: art/runtime/indirect_reference_table.cc:127] 
03-23 13:25:56.781 3493-3573/? D/StatusBarManagerService: manageDisableList userId=0 what=0x0 pkg=Window{5a171b1 u0 d0 Starting de.everskill.everskill.debug}
03-23 13:25:56.791 3035-3035/? D/libEGL: eglInitialize EGLDisplay = 0x7fff60dac8
03-23 13:25:56.791 1976-1976/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-23 13:25:56.791 1976-1976/? A/DEBUG: Build fingerprint: 'samsung/zerofltexx/zeroflte:6.0.1/MMB29K/G920FXXU5DQA7:user/release-keys'
03-23 13:25:56.791 1976-1976/? A/DEBUG: Revision: '11'
03-23 13:25:56.791 1976-1976/? A/DEBUG: ABI: 'arm64'
03-23 13:25:56.791 1976-1976/? A/DEBUG: pid: 8120, tid: 8699, name: pool-2-thread-1  >>> de.everskill.everskill.debug <<<
03-23 13:25:56.791 1976-1976/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-23 13:25:56.811 1976-1976/? A/DEBUG: Abort message: 'art/runtime/indirect_reference_table.cc:127] JNI ERROR (app bug): local reference table overflow (max=512)'
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x0   0000000000000000  x1   00000000000021fb  x2   0000000000000006  x3   0000000000000000
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x4   0000000000000000  x5   0000000000000001  x6   0000000000000000  x7   0000000000000000
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x8   0000000000000083  x9   0000000000016240  x10  000000000057d960  x11  000000000057daa0
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x12  0000000000000000  x13  0000007f960f5000  x14  0000000000000000  x15  0000007f960e7000
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x16  0000007f960e7568  x17  0000007f9607a338  x18  0000000000000000  x19  0000007f59dff500
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x20  0000007f59dff440  x21  0000000000000011  x22  0000000000000006  x23  0000007f64056240
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x24  0000007f9236cbc0  x25  0000007f78ac5200  x26  0000007f92475bc0  x27  0000000000000001
03-23 13:25:56.811 1976-1976/? A/DEBUG:     x28  0000007f64056100  x29  0000007f59dfe8b0  x30  0000007f96077ad4
03-23 13:25:56.811 1976-1976/? A/DEBUG:     sp   0000007f59dfe8b0  pc   0000007f9607a340  pstate 0000000020000000
03-23 13:25:56.821 1976-1976/? A/DEBUG: backtrace:
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #00 pc 0000000000069340  /system/lib64/libc.so (tgkill+8)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #01 pc 0000000000066ad0  /system/lib64/libc.so (pthread_kill+68)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #02 pc 0000000000023910  /system/lib64/libc.so (raise+28)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #03 pc 000000000001e240  /system/lib64/libc.so (abort+60)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #04 pc 0000000000430e38  /system/lib64/libart.so (_ZN3art7Runtime5AbortEv+304)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #05 pc 00000000001373a4  /system/lib64/libart.so (_ZN3art10LogMessageD2Ev+3136)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #06 pc 0000000000272f88  /system/lib64/libart.so (_ZN3art22IndirectReferenceTable3AddEjPNS_6mirror6ObjectE+372)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #07 pc 000000000035bff0  /system/lib64/libart.so (_ZN3art3JNI21GetObjectArrayElementEP7_JNIEnvP13_jobjectArrayi+472)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #08 pc 0000000000156ee0  /system/lib64/libart.so (_ZN3art8CheckJNI21GetObjectArrayElementEP7_JNIEnvP13_jobjectArrayi+524)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #09 pc 0000000000052ef4  /data/app/de.everskill.everskill.debug-3/lib/arm64/librealm-jni.so (Java_io_realm_internal_TableQuery_nativeBatchUpdateQueries+616)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #10 pc 00000000018e6d40  /data/app/de.everskill.everskill.debug-3/oat/arm64/base.odex (offset 0xddf000) (long[] io.realm.internal.TableQuery.nativeBatchUpdateQueries(long, long[], long[][], long[][], boolean[][])+244)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #11 pc 0000000001903578  /data/app/de.everskill.everskill.debug-3/oat/arm64/base.odex (offset 0xddf000) (void io.realm.internal.async.QueryUpdateTask.run()+588)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #12 pc 0000000001900748  /data/app/de.everskill.everskill.debug-3/oat/arm64/base.odex (offset 0xddf000) (void io.realm.internal.async.BgPriorityRunnable.run()+140)
03-23 13:25:56.821 1976-1976/? A/DEBUG:     #13 pc 0000000003492ec0  /system/framework/arm64/boot.oat (offset 0x2f48000)

我从googleing得到的是我基本上没有清理我分配的内存,因为我从不离开活动,垃圾收集器不会自动完成。

所以我需要手动释放已分配的内存。但是你可以向我暗示要寻找什么吗? 什么样的元素在这个JNI表中分配内存? 什么是JNI表? 我如何释放表中的记忆?

非常感谢! 最好 TobHo

0 个答案:

没有答案