gpt4 book ai didi

java - Andrjoid JNI简单,接下来返回错误

转载 作者:行者123 更新时间:2023-11-30 18:03:30 24 4
gpt4 key购买 nike

    jstring Java_com_example_hellojni_HelloJni_buildString(JNIEnv *env, jobject sThis){
for (int i=0; i < 100000; i++){
char* c=(char*)env->NewStringUTF("xx");
}

return env->NewStringUTF("test");
}

12-04 14:46:36.399: DEBUG/dalvikvm(8086): Trying to load lib /data/data/com.example.hellojni/lib/libhello-jni.so 0x405143d8 12-04 14:46:36.399: DEBUG/dalvikvm(8086): Added shared lib /data/data/com.example.hellojni/lib/libhello-jni.so 0x405143d8 12-04 14:46:36.431: WARN/dalvikvm(8086): ReferenceTable overflow (max=1024) 12-04 14:46:36.431: WARN/dalvikvm(8086): Last 10 entries in JNI local reference table: 12-04 14:46:36.431: WARN/dalvikvm(8086): 1014: 0x4052b258 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1015: 0x4052b298 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1016: 0x4052b2d8 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1017: 0x4052b318 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1018: 0x4052b358 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1019: 0x4052b398 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1020: 0x4052b3d8 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1021: 0x4052b418 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1022: 0x4052b458 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1023: 0x4052b498 cls=Ljava/lang/String; (28 bytes) 12-04 14:46:36.431: WARN/dalvikvm(8086): JNI local reference table summary (1024 entries): 12-04 14:46:36.431: WARN/dalvikvm(8086): 1 of Ljava/lang/Class; 236B 12-04 14:46:36.431: WARN/dalvikvm(8086):
1 of Ljava/lang/Class; 284B 12-04 14:46:36.431: WARN/dalvikvm(8086):
1 of Ljava/lang/Class; 572B 12-04 14:46:36.431: WARN/dalvikvm(8086): 1020 of Ljava/lang/String; 28B (1020 unique) 12-04 14:46:36.431: WARN/dalvikvm(8086): 1 of [Ljava/lang/String; 28B 12-04 14:46:36.431: WARN/dalvikvm(8086): Memory held directly by tracked refs is 29680 bytes 12-04 14:46:36.431: ERROR/dalvikvm(8086): Failed adding to JNI local ref table (has 1024 entries) 12-04 14:46:36.431: INFO/dalvikvm(8086): "main" prio=5 tid=1 RUNNABLE 12-04 14:46:36.431: INFO/dalvikvm(8086): | group="main" sCount=0 dsCount=0 obj=0x4001f1b8 self=0xcee8 12-04 14:46:36.431: INFO/dalvikvm(8086):
| sysTid=8086 nice=0 sched=0/0 cgrp=default handle=-1345006496 12-04 14:46:36.431: INFO/dalvikvm(8086): at com.example.hellojni.HelloJni.buildString(Native Method) 12-04 14:46:36.431: INFO/dalvikvm(8086): at com.example.hellojni.HelloJni.onCreate(HelloJni.java:93)

奇怪。如果我的下一个看起来像这样:

for (int i=0; i < 100; i++){

然后一切都好。

如何重写此代码以运行带有大数字的 for next ?

最佳答案

如果您从 UI 线程调用此方法,那么它将暂停 1.4 分钟,并且 Android 将关闭任何 5 秒内没有响应的程序,这可以帮助您尝试使用 AsyncTask 或在另一个线程中执行此调用。

关于java - Andrjoid JNI简单,接下来返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8375744/

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