Listview Does Not Work On Fragment - Outofmemoryerror: Failed To Allocate
Solution 1:
Here's what I recommend, it should help...
You can ignore the problem not recommended and increase the heapSize by adding this to your android manifest file:
<application android:largeHeap="true"
Also set Bitmap.Config
type RGB_565
instead of ARGB_8888
to keep the bitmaps smaller.
But the best option here would be to take some time and profile your application with LeakCanary and take a look at this video to learn Memory Management for Android - Google I/O 2011: Memory management for Android Apps (Play from 4:12 to see why largeHeap=true
is bad.) then at 8:31 they go into detail on understanding heap usage.
The large heap fix it's a temporary fix and shouldn't be considered final. I highly recommend profiling, Take a look at the Fragment life cycle the method that is called before the Fragment is completely done with is the onDetach()
method, you may want to release all the resources here. The fact that a fragment itself is destroyed and gc'ed does not mean all resources you allocated were removed.
Post a Comment for "Listview Does Not Work On Fragment - Outofmemoryerror: Failed To Allocate"