wie die Freigabe bitmap-Speicher in android

In unserem Programm, wo Sie zu viele Bilder,wir unbindDrawables in jedem Activity-und Fragment wie unter

protected void unbindDrawables(View view) {
    if (view != null) {
        if (view.getBackground() != null) {
            view.getBackground().setCallback(null);
        }
        if (view instanceof ImageView) {
            ImageView imageView = (ImageView) view;
            imageView.setImageDrawable(null);
        }
        if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                unbindDrawables(((ViewGroup) view).getChildAt(i));
            }
            if (!(view instanceof AbsSpinner) && !(view instanceof AbsListView)) {
                ((ViewGroup) view).removeAllViews();
            }
        }
    }
}

wie diese https://stackoverflow.com/a/6779067 sagte,aber ich benutze die Matte finden Sie, dass die bitmap auch eine Menge Speicher und nicht loslassen.

Class Name                               |   Objects | Shallow Heap | Retained Heap

 android.graphics.Bitmap                 |       490 |       23,520 | >= 36,267,912
 android.graphics.Bitmap$1               |         1 |            8 |          >= 8
 android.graphics.Bitmap$2               |         0 |            0 |         >= 80
 android.graphics.Bitmap$BitmapFinalizer |       490 |        7,840 |      >= 7,840
 android.graphics.Bitmap$CompressFormat  |         3 |           72 |        >= 232
 android.graphics.Bitmap$CompressFormat[]|         1 |           24 |         >= 24
 android.graphics.Bitmap$Config          |         4 |           96 |        >= 360
 android.graphics.Bitmap$Config[]        |         2 |           72 |         >= 72
 android.graphics.BitmapFactory          |         0 |            0 |         >= 80
 android.graphics.BitmapFactory$Options  |         0 |            0 |              
 android.graphics.BitmapRegionDecoder    |         0 |            0 |         >= 48
 android.graphics.BitmapShader           |         9 |          216 |     >= 15,736
 Total: 12 entries (4,509 filtered)      |     1,000 |       31,848 |              

Ich weiß nicht, warum es nicht veröffentlicht werden und wie Sie zu lösen,jede Stelle kann mir helfen,vielen Dank!

Dieser link wird Ihnen helfen, dude : stackoverflow.com/questions/477572/...

InformationsquelleAutor telentqq | 2013-11-29

Schreibe einen Kommentar