If you must use (and save) a large amount of memory, then yes, you can and should use android:largeHeap="true" . But if you use it, you should be prepared for the fact that your application will be unloaded from memory when other applications are in the foreground.
By โprepare,โ I mean that you must design for this probability that your onStop() and onResume() be written as efficiently as possible, while ensuring that all relevant states are saved and restored in such a way that a perfect external view for the user.
There are three methods that relate to this parameter: maxMemory() , getMemoryClass() and getLargeMemoryClass() .
For most devices, maxMemory() will represent a value similar to default getMemoryClass() , although the latter is expressed in megabytes and the former in bytes.
When you use the largeHeap parameter, maxMemory() will be increased to a device-specific level, while getMemoryClass() will remain the same.
getMemoryClass() does not limit the heap size, but tells the heap volume that should be used if you want your application to function comfortably and compatible within the specific device on which you are working.
maxMemory() , in contrast, limits the size of the heap, so you access the extra heap by increasing its value, and largeHeap increases this value. However, the increased heap volume is still limited, and this limit will depend on the device, which means that the heap volume available to your application will vary depending on the resources of the device on which your application is running. Thus, using largeHeap is not an invitation for your application to give up all caution and go through the "all you can eat" buffet.
Your application can determine exactly how much memory will be available on a particular device using the largeHeap parameter by calling the getLargeMemoryClass() method. The return value in megabytes.
This previous post includes a discussion of the largeHeap parameter, as well as a number of examples of how largeHeap heap volumes are available with and without using it on several specific Android devices:
Determine heap size of application in Android
I have not deployed any of my own applications with this setting set to true. However, in one of my applications there is code that uses memory intensively to compile a set of parameters related to optimization, which is executed only during development. I add the largeHeap parameter only at design time to avoid largeHeap memory errors when executing this code. But I remove the parameter (and code) before deploying the application.