Android搭載端末の[ホーム]ボタンでアプリから離れた場所に移動し、ランチャーアイコンを使用してアプリをもう一度入力すると、アプリの初期アクティビティが重複します。ルーチンを5回繰り返すと、私の初期の活動の5つのインスタンスがあります。ホームボタンでナビゲートすると、自分のアクティビティがメモリリークを引き起こすのはなぜですか?
Eclipseでヒープダンプを使ってこれを監視し、各ダンプの前にガベージコレクトを行います。私はすべてのヒストグラムビューで私の活動のクラスの参照とGCルートへShortesパスをマージを求めるとき、これは私が取得図である:(?またはクラス)だから、財産があるように思える
Class Name | Ref. Objects | Shallow Heap | Ref. Shallow Heap | Retained Heap
-------------------------------------------------------------------------------------------------------------------------------------------------
| | | |
android.view.ViewRootImpl$WindowInputEventReceiver @ 0x41408a80 Native Stack | 1 | 32 | 224 | 184
class android.view.inputmethod.InputMethodManager @ 0x40d93e78 System Class | 1 | 88 | 224 | 616
'- mInstance android.view.inputmethod.InputMethodManager @ 0x413422e0 | 1 | 112 | 224 | 296
'- mServedView, mNextServedView android.widget.ListView @ 0x41331100 | 1 | 1 088 | 224 | 124 096
'- mContext nilsnett.chinese.activities.GameOverviewActivity @ 0x44eeecd8| 1 | 224 | 224 | 1 000
android.view.ViewRootImpl$WindowInputEventReceiver @ 0x41af4a60 Native Stack | 1 | 32 | 224 | 184
android.view.ViewRootImpl$WindowInputEventReceiver @ 0x412cf928 Native Stack | 1 | 32 | 224 | 184
android.view.ViewRootImpl$WindowInputEventReceiver @ 0x44cd3090 Native Stack | 1 | 32 | 224 | 184
'- this$0 android.view.ViewRootImpl @ 0x44cd1f20 | 1 | 464 | 224 | 2 168
'- mView com.android.internal.policy.impl.PhoneWindow$DecorView @ 0x44cbef00| 1 | 536 | 224 | 1 336
'- mContext nilsnett.chinese.activities.GameOverviewActivity @ 0x44cbdee8| 1 | 224 | 224 | 1 000
Total: 5 entries | 5 | 216 | 1 120 |
-------------------------------------------------------------------------------------------------------------------------------------------------
WindowInputEventReceiver
私の活動を参照しているGameOverviewActivity
。なぜ、それをやめたらいいですか?
マニフェストで 'android:singleInstance =" true "'を指定するとどうなりますか? –
アクティビティの開始時に設定しているInentフラグをチェックしてください...これは異常な動作です。漏れたコードがそこにある必要があります... – aProgrammer
ホームボタンを押したときに表示されるダイアログはありますか? –