1
for 루프 작업은 7 번이지만 그 이후에는 응용 프로그램 crash.in 메모리 그래프 그것은 124mb에 수준을 보여줍니다.응용 프로그램과 같은 사진 갤러리를 만들려고하지만 arraylist에 비트 맵 객체를 추가 할 때 클램프 대상 GC 힙을 128MB에서 128MB로 늘리는 중입니다.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
String path=Environment.getExternalStorageDirectory().toString()+"/Pictures";
File direct = new File(path);
File[] dirFiles=direct.listFiles();
ArrayList<Bitmap> arr= new ArrayList<>();
for (int i=0 ; i < dirFiles.length;i++){
Bitmap myBitmap = BitmapFactory.decodeFile(dirFiles[i].getAbsolutePath());
arr.add(myBitmap);
Log.v("image number",""+i);
}
//ImageAdapter imgAdp = new ImageAdapter(this,arr);
//ListView lv=(ListView)findViewById(R.id.rootView);
//lv.setAdapter(imgAdp);
}
"갤러리"애플 리케이션을 모두하지 않는 대신 이것은 당신이 파일을 사용하는 거라고 어떻게되는 ArrayList에 모든 비트 맵을 추가 Android-Universal-Image-Loader 같은 이미지 캐싱 라이브러리를 사용한다 비트 맵을 한번에 풀 해상도로 메모리에 저장한다. 당신은 그것에 대한 충분한 기억이 없을 것입니다. 이미지로드 라이브러리 (예 : 글라이드, 피카소)를 사용하면 이미지를 원하는 'ImageViews'에 맞게 축소하고 어댑터에서 필요에 따라 이미지를로드 할 수 있습니다. – CommonsWare