Ich habe A und B Aktivitäten. Wenn ich Aktivität B aus Aktivität A starte, setze ich eine statische Bitmap-Variable auf Aktivität B. Ich zeige diese Bitmap auf dem Bildschirm an und drehe sie.Speicherverbrauch sinkt nicht auch ich recycle Bitmaps
Wenn Aktivität B beendet ist, recycle ich alle Bitmaps on onDestroy() -Methode, aber die Speicherauslastung nimmt nicht ab.
@Override
protected void onDestroy() {
super.onDestroy();
if (bitmap90 != null) {
bitmap90.recycle();
bitmap90 = null;
}
if (bitmap180 != null) {
bitmap180.recycle();
bitmap180 = null;
}
if (bitmap270 != null) {
bitmap270.recycle();
bitmap270 = null;
}
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
if (((BitmapDrawable) ivOriginal.getDrawable()).getBitmap() != null) {
((BitmapDrawable) ivOriginal.getDrawable()).getBitmap().recycle();
ivOriginal.setImageDrawable(null);
}
if (((BitmapDrawable) ivOriginal90.getDrawable()).getBitmap() != null) {
((BitmapDrawable) ivOriginal90.getDrawable()).getBitmap().recycle();
ivOriginal90.setImageDrawable(null);
}
System.gc();
}
Vielleicht haben Sie woanders einen Verweis auf Ihre Bitmaps. Im Allgemeinen wird von der Verwendung statischer Eigenschaften abgeraten. Warum speichern Sie Ihre Bitmaps nicht in einer Datei und lesen sie dann in Ihrer B-Aktivität? –