未能增加JNI本地参考表(有512项)当资源添加到阵列 [英] Failed adding to JNI local ref table (has 512 entries) When Add resources to Array

查看:147
本文介绍了未能增加JNI本地参考表(有512项)当资源添加到阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图让我得到错误的所有引用到数组。未能增加JNI本地参考表(有512项)。

我试着去阅读所有字符串到像数组:

 的String [] = aStrings mAppContext.getResources()。getStringArray(R.array.a_array)

在XML我有500+行的字符串,如:

 <字符串数组名=a_array>
    <项目> 0 @ 100 @名1< /项目>
    <项目> 1 @ 101 @名2< /项目>
    ...
    ...
    ...
    <项目> 600 @ 101 @ name600< /项目>
< /字符串数组>

如果我在注2为例运行我的code(4 +)的一切工作正常,如果我在野火(2 +),我得到的错误运行它。如果我减少条目波纹管500然后一切工作正常。我相信这个错误,我得到的是因为旧设备上的内存不足。当错误发生applicatin崩溃。

现在我有两个问题:


  1. 我能避免这个错误?在某种程度上解决这个问题?让我的应用程序woun't崩溃。

  2. 有没有办法赶上这个错误,并加载较小的阵列? (我trye​​d与try catch块,但没有成功)


解决方案

我没有解决这个问题。创造insted的<字符串数组名=a_array> 我创建:

 <字符串名称=a_array>
  0 @ 100 @#名1
  1 @ 101 @#NAME2
  ...
  ...
  ñ@ N @ nameN
< /串>

和比我读字符串转换成变量,并用 .split(#); 解析到数组

When I try to get all references into array I get error. Failed adding to JNI local ref table (has 512 entries).

I try to read all strings into Array like:

String[] aStrings = mAppContext.getResources().getStringArray(R.array.a_array)

in xml i have 500+ lines of strings, like:

<string-array name="a_array">
    <item>0@100@Name1</item>
    <item>1@101@name2</item>
    ...
    ...
    ...
    <item>600@101@name600</item>
</string-array>

If i run my code in for exemple note2(4.+) everything works ok, if I run it in wildfire(2.+) I get error. If i reduce entries bellow 500 then everything works ok. I belive that error that I get is because of low memory on older device. When error happens applicatin crash.

Now I got two questions:

  1. can I avoid this error? somehow fix this? so that my app woun't crash.
  2. is there a way to catch this error and load smaller array? (I tryed with try catch block, but no success)

解决方案

I did fix the problem. Insted of creating <string-array name="a_array"> I created:

<string name="a_array">
  0@100@Name1#
  1@101@name2#
  ...
  ...
  N@N@nameN
</string>

And than i read string into variable, and with .split("#"); parse it into array.

这篇关于未能增加JNI本地参考表(有512项)当资源添加到阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆