안녕하세요.


비트맵을 추가를 하려고 하는데 out of memory 가 발생을 하여

이것저것 찾아보다 메모리 체크를 하는 소스를 적용해보았습니다.

아래가 소스와 나온 결과 값인데요.(갤럭시노트 U+)


android.util.Log.d(TAG,"Native heap size: "+(Debug.getNativeHeapSize() / (1024)) + "KB");

android.util.Log.d(TAG,"Heap Free size : "+(Debug.getNativeHeapFreeSize() / (1024)) + "KB");

android.util.Log.d(TAG,"Heap Allocated size : "+(Debug.getNativeHeapAllocatedSize() / (1024)) + "KB");

android.util.Log.d(TAG,"TOTAL MEMORY : "+(Runtime.getRuntime().totalMemory() / (1024 * 1024)) + "MB");

android.util.Log.d(TAG,"MAX MEMORY : "+(Runtime.getRuntime().maxMemory() / (1024 * 1024)) + "MB");

android.util.Log.d(TAG,"FREE MEMORY : "+(Runtime.getRuntime().freeMemory() / (1024 * 1024)) + "MB");

android.util.Log.d(TAG,"ALLOCATION MEMORY : "+((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "MB");


제목 없음.png


이미지를 보시면 heap free size가 178k 인데 20k 짜리 이미지를 올려도

out of memory on a 2457616-byte allocation

이런 문구가 나옵니다.

100k를 올려도 위와 같이 동일한 문구가 나옵니다.


조언 부탁드립니다.


profile

give & take