Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 帮助破译logcat输出-JNI全局引用过多_C#_Android_Memory Management_Java Native Interface_Xamarin.android - Fatal编程技术网

C# 帮助破译logcat输出-JNI全局引用过多

C# 帮助破译logcat输出-JNI全局引用过多,c#,android,memory-management,java-native-interface,xamarin.android,C#,Android,Memory Management,Java Native Interface,Xamarin.android,有人能给我一些提示,说明是什么原因导致我的应用程序中止并给出这个输出吗 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):

有人能给我一些提示,说明是什么原因导致我的应用程序中止并给出这个输出吗

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
StudentList.cs的代码

使用系统;
使用Android.App;
使用Android.Content;
使用Android.Runtime;
使用Android.Views;
使用Android.Widget;
使用Android.OS;
使用monmap;
使用MonoMap.wsMobile;
命名空间映射机器人
{
公共班级学生名单:活动
{
private int currentFacultyId=93306;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
//显示加载布局
SetContentView(Resource.Layout.SplashLoad);
//初始化AsycTask并执行
GetStudentsTask gstask=新GetStudentsTask(此,currentFacultyId);
gstask.Execute();
}
/***
*GetStudentsTask完成后的回调
* 
**/
受保护的无效显示列表(ArrayAdapter适配器)
{
SetContentView(Resource.Layout.LayoutStudentList);
//抢眼
ListView lvStudent=FindViewById(Resource.Id.studentListView);
EditText etFilter=FindViewById(Resource.Id.studentFilter);
//将适配器连接到ListView
lvStudent.Adapter=适配器;
//使用委托筛选文本更改的列表
etFilter.TextChanged+=委托(对象发送者,Android.Text.textchangedventargs e)
{
adapter.Filter.InvokeFilter(例如Text.ToString());
};
//使用delagate在ItemClick上激发意图
lvStudent.ItemClick+=委托(对象发送者、ItemEventArgs args args)
{
学生选择学生=适配器.GetItem(参数位置);
意向意向=新意向(此,类型为(选项卡视图));
intent.PutExtra(“studentId”,selectedStudent.I.ToString());
intent.PutExtra(“studentName”,selectedStudent.F.ToString()+”+selectedStudent.L.ToString());
intent.PutExtra(“facultyId”,currentFacultyId.ToString());
星触觉(意向);
};  
}
/**
*AsycTask实现以获取所有相关学生
* 
*/ 
内部类GetStudentsTask:AsyncTask
{
专用阵列适配器;
私立学生名单;
私人国际金融机构;
公共GetStudentsTask(外部学生列表,内部currentFacultyId)
{
这个。_outer=outer;
此._facId=currentFacultyId;
}
受保护的重写Java.Lang.Object DoInBackground(params Java.Lang.Object[]@params)
{
//设置适配器数据源
学生[]学生=WebService.GetStudentListbyFacultyId(\u facId);
_适配器=新阵列适配器(_outer,Resource.Layout.itemstustudent,students);
返回true;
}
受保护的重写void OnPostExecute(Java.Lang.Object结果)
{
_外部显示列表(_适配器);
base.OnPostExecute(结果);
}
}
}
}
另一个奇怪的问题是,它在实际设备上运行得很干净,但在模拟器上运行时,它会给我这个输出并中止


Ideas?

模拟器上的全局引用限制为2000。在设备上,如果我没记错的话,它大约是52000。你正在做的事情是创建并保留过多的对象。

是的,我推断这是一个调用
Student[]students=WebService.GetStudentListbyFacultyId(\u facId)。如何处理来自web服务的可变数据量?有什么方法可以超越emulator的限制?
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);
            }
        }
    }
}