I want to show the Bitmap image in ImageView from sd card which is stored already. After run my application is crash and getting Ou
Use Glide Library and Override size to less size;
Glide.with(mContext).load(imgID).asBitmap().override(1080, 600).into(mImageView);
In some cases (e.g. operations in a loop) garbage collector is slower than your code. You can use a helper method from this answer to wait for garbage collector.
This worked for me: just move images from drawable folder to drawable-hdpi.
For me, the problem was that my .png file was being de-compressed to be a really huge bitmap in memory, because the image had very large dimensions (even though the file size was tiny).
So the fix was to simply resize the image :)
Issue : Failed to allocate a 37748748 byte allocation with 16777120 free bytes and 17MB until OOM
Solution : 1.open your manifest file 2. inside application tag just add below two lines
android:hardwareAccelerated="false"
android:largeHeap="true"
Example :
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:largeHeap="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
add this to your manifest under applications? android:largeHeap="true"