-1

This application has MainActivity and it uses about 20 bitmaps. It works pretty fine but when I start an intent to another activity and then go back to the MainActivity, it crashes because of memory problem. It gives this error:

java.lang.OutOfMemoryError: Failed to allocate a 2052108 byte allocation with 1629176 free bytes and 1590KB until OOM

I have also used these in the manifest

android:hardwareAccelerated="false"
android:largeHeap="true"

What would be the best method to be able to switch between Activities without using more memory? Thanks

bibek
  • 1
  • 1
  • 3
    Possible duplicate of [Android:java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM](https://stackoverflow.com/questions/32244851/androidjava-lang-outofmemoryerror-failed-to-allocate-a-23970828-byte-allocatio) – Arya Feb 26 '18 at 07:36
  • you can consider using glide or picasso to handle the bitmap caching. this prevents the bitmap from loading multiple times and reuse bitmaps that's already loaded. – Angel Koh Feb 26 '18 at 07:41

1 Answers1

0

you just recycle bitmap when there is no longer in used

myBitmap.recycle();
Mitesh Machhoya
  • 404
  • 2
  • 8