帮助破译logcat的输出 - 过度JNI全局引用 [英] Help Decipher logcat output - Excessive JNI global references

查看:282
本文介绍了帮助破译logcat的输出 - 过度JNI全局引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我任何暗示什么可能会导致我的应用程序中止,并给这个输出?

Can anyone give me any hints on what could be causing my app to abort and give this output?

I/ActivityManager(   68): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=MapDroid.MapDroid/mapdroid.StudentList } from pid 223
I/ActivityManager(   68): Start proc MapDroid.MapDroid for activity MapDroid.MapDroid/mapdroid.StudentList: pid=506 uid=10036 gids={3003}
I/ActivityThread(  506): Pub MapDroid.MapDroid.__mono_init__: mono.MonoRuntimeProvider
D/dalvikvm(  506): Trying to load lib /data/data/MapDroid.MapDroid/lib/libmonodroid.so 0x40512d80
D/dalvikvm(  506): Added shared lib /data/data/MapDroid.MapDroid/lib/libmonodroid.so 0x40512d80
D/dalvikvm(  506): GC_CONCURRENT freed 1219K, 57% free 2906K/6727K, external 1625K/2137K, paused 19ms+5ms
I/ActivityManager(   68): Displayed MapDroid.MapDroid/mapdroid.StudentList: +16s949ms
D/dalvikvm(  223): GC_EXPLICIT freed 41K, 50% free 2940K/5767K, external 5937K/7285K, paused 88ms
D/dalvikvm(  506): GC_EXPLICIT freed 177K, 56% free 2976K/6727K, external 1671K/2137K, paused 71ms
D/dalvikvm(  506): GC_FOR_MALLOC freed 2K, 56% free 2974K/6727K, external 1671K/2137K, paused 50ms
I/dalvikvm-heap(  506): Grow heap (frag case) to 7.125MB for 22008-byte allocation
D/dalvikvm(  506): GC_FOR_MALLOC freed 0K, 56% free 2995K/6791K, external 1671K/2137K, paused 72ms
D/dalvikvm(  506): GREF has increased to 201
D/dalvikvm(  506): GREF has increased to 301
D/dalvikvm(  506): GREF has increased to 401
D/dalvikvm(  506): GREF has increased to 501
D/dalvikvm(  506): GREF has increased to 601
D/dalvikvm(  506): GREF has increased to 701
D/dalvikvm(  506): GREF has increased to 801
D/dalvikvm(  506): GREF has increased to 901
D/dalvikvm(  506): GREF has increased to 1001
D/dalvikvm(  506): GREF has increased to 1101
D/dalvikvm(  506): GREF has increased to 1201
D/dalvikvm(  506): GREF has increased to 1301
D/dalvikvm(  506): GREF has increased to 1401
D/dalvikvm(  506): GREF has increased to 1501
D/dalvikvm(  506): GREF has increased to 1601
D/dalvikvm(  506): GREF has increased to 1701
D/dalvikvm(  506): GREF has increased to 1801
D/dalvikvm(  506): GREF has increased to 1901
D/dalvikvm(  506): GREF has increased to 2001
W/dalvikvm(  506): Last 10 entries in JNI global reference table:
W/dalvikvm(  506):  1991: 0x40567bf0 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1992: 0x40567c00 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1993: 0x40567b60 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1994: 0x40567b70 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1995: 0x40567b80 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1996: 0x40561ab8 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1997: 0x40561ac8 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1998: 0x40561ad8 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  1999: 0x4055eef0 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506):  2000: 0x4055ef00 cls=Lmono/android/runtime/JavaObject; (12 bytes)
W/dalvikvm(  506): JNI global reference table summary (2001 entries):
W/dalvikvm(  506):    50 of Ljava/lang/Class; 164B (40 unique)
W/dalvikvm(  506):    47 of Ljava/lang/Class; 188B (17 unique)
W/dalvikvm(  506):     6 of Ljava/lang/Class; 212B (6 unique)
W/dalvikvm(  506):    11 of Ljava/lang/Class; 236B (6 unique)
W/dalvikvm(  506):     2 of Ljava/lang/Class; 260B (2 unique)
W/dalvikvm(  506):     5 of Ljava/lang/Class; 284B (2 unique)
W/dalvikvm(  506):     6 of Ljava/lang/Class; 308B (5 unique)
W/dalvikvm(  506):     3 of Ljava/lang/Class; 332B (2 unique)
W/dalvikvm(  506):     1 of Ljava/lang/Class; 356B
W/dalvikvm(  506):     2 of Ljava/lang/Class; 380B (1 unique)
W/dalvikvm(  506):     2 of Ljava/lang/Class; 428B (2 unique)
W/dalvikvm(  506):     1 of Ljava/lang/Class; 452B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 476B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 500B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 548B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 572B
W/dalvikvm(  506):     2 of Ljava/lang/Class; 596B (2 unique)
W/dalvikvm(  506):     1 of Ljava/lang/Class; 692B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 1004B
W/dalvikvm(  506):     2 of Ljava/lang/Class; 1172B (2 unique)
W/dalvikvm(  506):     1 of Ljava/lang/Class; 1316B
W/dalvikvm(  506):     1 of Ljava/lang/Class; 3452B
W/dalvikvm(  506):     1 of Ljava/lang/String; 28B
W/dalvikvm(  506):     2 of Ldalvik/system/VMRuntime; 12B (1 unique)
W/dalvikvm(  506):     9 of Ljava/lang/ref/WeakReference; 28B (9 unique)
W/dalvikvm(  506):     1 of Ljava/lang/ref/WeakReference; 36B
W/dalvikvm(  506):     1 of Ldalvik/system/PathClassLoader; 44B
W/dalvikvm(  506):     1 of Landroid/app/ActivityThread$ApplicationThread; 28B
W/dalvikvm(  506):     1 of Landroid/content/ContentProvider$Transport; 28B
W/dalvikvm(  506):     1 of Landroid/view/inputmethod/InputMethodManager$ControlledInputConnectionWrapper; 36B
W/dalvikvm(  506):     1 of Landroid/view/ViewRoot$1; 12B
W/dalvikvm(  506):     1 of Landroid/view/ViewRoot$W; 28B
W/dalvikvm(  506):     1 of Landroid/view/inputmethod/InputMethodManager$1; 28B
W/dalvikvm(  506):     1 of Landroid/view/accessibility/AccessibilityManager$1; 28B
W/dalvikvm(  506):     2 of Lorg/apache/harmony/xnet/provider/jsse/TrustManagerImpl; 28B (1 unique)
W/dalvikvm(  506):     1 of Lmapdroid/StudentList_GetStudentsTask; 28B
W/dalvikvm(  506):  1099 of Lmono/android/runtime/JavaObject; 12B (1099 unique)
W/dalvikvm(  506):   729 of Lmono/android/runtime/JavaObject; 20B (729 unique)
W/dalvikvm(  506):     1 of Lmapdroid/StudentList; 180B
W/dalvikvm(  506): Memory held directly by tracked refs is 58440 bytes
E/dalvikvm(  506): Excessive JNI global references (2001)
E/dalvikvm(  506): VM aborting
D/Zygote  (   33): Process 506 exited cleanly (1)
I/ActivityManager(   68): Process MapDroid.MapDroid (pid 506) has died.
I/WindowManager(   68): WIN DEATH: Window{406a8598 MapDroid.MapDroid/mapdroid.StudentList paused=false}
W/InputManagerService(   68): Got RemoteException sending setActive(false) notification to pid 506 uid 10036

code为StudentList.cs

Code for StudentList.cs

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using MonoMap;
using MonoMap.wsMobile;

namespace MapDroid
{
    public class StudentList : Activity
    {

        private int currentFacultyId = 93306;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Show Loading Layout
            SetContentView(Resource.Layout.SplashLoad);

            // init AsycTask and Execute
            GetStudentsTask gstask = new GetStudentsTask(this, currentFacultyId);
            gstask.Execute();

        }

        /***
         * Callback after GetStudentsTask completes
         * 
         **/
        protected void ShowList(ArrayAdapter<Student> adapter)
        {
            SetContentView(Resource.Layout.LayoutStudentList);

            //Grab Views
            ListView lvStudent = FindViewById<ListView>(Resource.Id.studentListView);
            EditText etFilter = FindViewById<EditText>(Resource.Id.studentFilter);

            //Attach Adapter to ListView
            lvStudent.Adapter = adapter;

            //Use delegate to filter list on TextChanged
            etFilter.TextChanged += delegate(object sender, Android.Text.TextChangedEventArgs e)
            {
                adapter.Filter.InvokeFilter(e.Text.ToString());
            };

            //Use delagate to fire intent on ItemClick
            lvStudent.ItemClick += delegate(object sender, ItemEventArgs args)
            {
                Student selectedStudent = adapter.GetItem(args.Position);
                Intent intent = new Intent(this, typeof(TabbedView));
                intent.PutExtra("studentId", selectedStudent.I.ToString());
                intent.PutExtra("studentName", selectedStudent.F.ToString() + " " + selectedStudent.L.ToString());
                intent.PutExtra("facultyId", currentFacultyId.ToString());
                StartActivity(intent);
            };  
        }

        /**
         * AsycTask Implementation to Get All Associated Students
         * 
         */ 
        internal class GetStudentsTask : AsyncTask
        {

            private ArrayAdapter<Student> _adapter;
            private StudentList _outer;
            private int _facId;

            public GetStudentsTask(StudentList outer, int currentFacultyId)
            {
                this._outer = outer;
                this._facId = currentFacultyId;
            }

            protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
            {
                //Setup Adapter Data Source
                Student[] students = WebService.GetStudentListbyFacultyId(_facId);
                _adapter = new ArrayAdapter<Student>(_outer, Resource.Layout.ItemStudent, students);
                return true;
            }

            protected override void OnPostExecute(Java.Lang.Object result)
            {
                _outer.ShowList(_adapter);
                base.OnPostExecute(result);
            }
        }
    }
}

另一个奇怪的皱纹添加到褶皱是它顺利运行在实际设备上,但在试图在模拟器上运行它,它给了我这个输出并中止...

Another strange wrinkle to add to the fold is that it runs cleanly on an actual device, but in trying to run it on an emulator it gives me this output and aborts...

想法?

推荐答案

在模拟器上的全球参考限值是2000在设备上,它是〜52000如果我没有记错。有些事情,你正在做的是创造和持有的对象过量。

The global ref limit on the emulator is 2000. On the device, it is ~52000 if I recall correctly. Something you are doing is creating and holding on to an excessive amount of objects.

这篇关于帮助破译logcat的输出 - 过度JNI全局引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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