gpt4 book ai didi

android 过多的全局引用

转载 作者:行者123 更新时间:2023-11-29 00:49:52 24 4
gpt4 key购买 nike

我偶尔会触发 android 模拟器的 jni 全局引用限制。我试图在我的应用程序中存储大约 2000 个单词和定义,但它在两个位置中的任何一个都失败了:如果我使用 DOM 来解析包含所有这些引用的 xml 文件,当 DOM 将树拉入内存时它会失败。如果我使用 SAX,当我到达第 2000 个元素时它会失败。

有没有人提供我如何禁用检查的链接(我知道它在实际机器上不存在,我试图在内存中保留 2000 个小对象)?如果没有,是否有调试的好方法?正在构建的对象是字符串:

09-20 16:24:00.278: WARN/dalvikvm(625):  1879 of Ljava/lang/String; 28B (1877 unique)

我尝试使用 -nojni 启动 avd 并使用 adb 设置 dalvik.vm.checkjni

C:\android-sdk-windows\tools>adb shell getprop dalvik.vm.checkjni
false

虽然 logcat 显示“CheckJNI is Off”,但它仍然死于 globalref 2001 限制。

此外,在解析部分之后,如我所见,内存最终会返回:

09-20 16:31:23.238: DEBUG/dalvikvm(654): GC_EXPLICIT freed 1157 objects / 48208 bytes in 147ms
09-20 16:31:23.258: DEBUG/dalvikvm(654): GREF has decreased to 1799
09-20 16:31:23.278: DEBUG/dalvikvm(654): GREF has decreased to 1699
09-20 16:31:23.287: DEBUG/dalvikvm(654): GREF has decreased to 1599
09-20 16:31:23.309: DEBUG/dalvikvm(654): GREF has decreased to 1499
09-20 16:31:23.328: DEBUG/dalvikvm(654): GREF has decreased to 1399
09-20 16:31:23.338: DEBUG/dalvikvm(654): GREF has decreased to 1299
09-20 16:31:23.367: DEBUG/dalvikvm(654): GREF has decreased to 1199
09-20 16:31:23.367: DEBUG/dalvikvm(654): GREF has decreased to 1099
09-20 16:31:23.398: DEBUG/dalvikvm(654): GREF has decreased to 999
09-20 16:31:23.398: DEBUG/dalvikvm(654): GREF has decreased to 899
09-20 16:31:23.408: DEBUG/dalvikvm(654): GREF has decreased to 799
09-20 16:31:23.418: DEBUG/dalvikvm(654): GREF has decreased to 699
09-20 16:31:23.418: DEBUG/dalvikvm(654): GREF has decreased to 599
09-20 16:31:23.437: DEBUG/dalvikvm(654): GREF has decreased to 499
09-20 16:31:23.447: DEBUG/dalvikvm(654): GREF has decreased to 399
09-20 16:31:23.447: DEBUG/dalvikvm(654): GREF has decreased to 299
09-20 16:31:23.469: DEBUG/dalvikvm(654): GREF has decreased to 199

所以我不认为我的 hashmap 包含单词对象才是真正的问题所在。我剩下的唯一想法是将 xml 文件切成多个,但这似乎是一个可能不雅的解决方案。

非常感谢!

最佳答案

这是我们基于 expat 的 XML 解析器(SAX 和 pull)中的一个错误:http://code.google.com/p/android/issues/detail?id=12595

关于android 过多的全局引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3754989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com