4 개의 탭 (TabActivity)이있는 응용 프로그램이 있습니다. 몇 가지 이유로 GC.Collect를 호출 할 때마다 사용자가 탭을 전환 할 때마다 (OnPause Activity 메서드 무시). 때로는 (약 50-100 통화에서 약 1 시간이지만 때로는 응용 프로그램이 시작될 때 이런 일이 발생 함)이 순간에 내 응용 프로그램이 중단됩니다. 여기 Monodroid - GC.Collect가 아무런 이유없이 실패했습니다.
protected override void OnPause(){
base.OnPause();
try{
Android.Util.Log.Info("----","GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);");
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
Android.Util.Log.Info("----","GC.Collect Finished");
}catch(Exception exc){
Android.Util.Log.Info("exc.Message",exc.Message);
Android.Util.Log.Info("exc.StackTrace",exc.StackTrace);
throw exc;
}
}
그리고
안드로이드 로그 출력을 던진에//Previous GC.Collect call, it's all ok
I/---- (7796): GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
D/dalvikvm(7796): GetMethodID: method not found: Landroid/widget/EditText;.monodroidAddReference:(Ljava/lang/Object;)V
D/dalvikvm(7796): GC_EXPLICIT freed 962 objects/42472 bytes in 112ms
I/---- (7796): GC.Collect Finished
//On another call fails
I/---- (7796): GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
I/mono (7796): Stacktrace:
I/mono (7796):
I/mono (7796): at System.GC.Collect (int) <0x0001f>
I/mono (7796): at System.GC.Collect (int,System.GCCollectionMode) <0x00017>
I/mono (7796): at PixelsAndroid.CustomActivity.OnPause() <0x00067>
I/mono (7796): at Android.App.Activity.n_OnPause (intptr,intptr) <0x00037>
I/mono (7796): at (wrapper dynamic-method) object.908cefd4-40eb-4dd1-97cd-f731b2ada74a (intptr,intptr) <0x0002b>
I/mono (7796): at (wrapper native-to-managed) object.908cefd4-40eb-4dd1-97cd-f731b2ada74a (intptr,intptr) <0xffffffff>
없음 예외, 실패없이 보이는 이유에 해당한다 : 여기
내 코드의 일부입니다. 응용 프로그램이 멈추고 몇 초 후에 Android OS 알림이 표시됩니다. "Oppps, 응용 프로그램이 멈췄습니다. 강제 종료 또는 대기?"
아무도 그것에 직면 해 있지 않습니까?
처음에 GC.Collect()를 호출하는 이유는 무엇입니까? 그 문제에 대해 MonoDroid 나 Windows에서 GC를 강제 실행하는 유효한 이유가 없었습니다. GC.Collect()를 보면 다시 생각해야 할 코드 냄새입니다. –
[이 문제는] 특정 솔루션처럼 사용하십시오 (http://stackoverflow.com/questions/7603135/monodroid-passing-data-to-listview-according-to-gref-limit) – PVoLan
인스턴스 수 줄이기 로드. 솔직히 말하자면 : GREF 한도 (즉, 데이터를 페이징하지 않음)에 도달하는 목록 항목이 너무 많이로드되는 경우 솔루션을 재 설계해야합니다. 기억하십시오, 이것은 모바일 장치가 아니라 랩톱/데스크탑/무엇이든합니다. –