Storing a Bitmap resource in a static variable을 추적하면 android.graphics.Bitmap
의 정적 참조를 View
에 저장하면 해당 인스턴스를 초기화 한 해당 View
에 대한 참조가 누수 될 수 있습니다. Android에서 이것을 해결하는 관용적 인 방법은 무엇입니까? 이 뷰의 인스턴스가 인스턴스화 될 때마다 BitmapFactory.decodeResource(resource, id)
에 전화하기를 원하지 않습니다.이 작업은 모든 단일 활동에서 (여러 번) 수행 될 것이기 때문입니다. 이 작은 Bitmap
이 항상 메모리에 남아 있기를 원합니다. 그럼, 다음을 수행하는 올바른 방법은 무엇입니까 :메모리에 비트 맵을 유지하는 방법
public class MyView extends View {
private static Bitmap star;
public MyView(Context context) {
synchronized(this) {
if (star == null) {
star = BitmapFactory.decodeResource(getResources(), R.drawable.star);
}
}
}
// ...
}
응용 프로그램 클래스에 비트 맵을 넣으면 참조를 지워야합니까? – Kostadin