What are advantages of setting largeHeap to true?
Way too late for the party here, but i will offer my 0.02$ anyways.
It's not a good idea to use android:largeHeap="true"
here's the extract from google that explains it,
However, the ability to request a large heap is intended only for a
small set of apps that can justify the need to consume more RAM (such
as a large photo editing app). Never request a large heap simply
because you've run out of memory and you need a quick fix—you should
use it only when you know exactly where all your memory is being
allocated and why it must be retained. Yet, even when you're confident
your app can justify the large heap, you should avoid requesting it to
whatever extent possible. Using the extra memory will increasingly be
to the detriment of the overall user experience because garbage
collection will take longer and system performance may be slower when
task switching or performing other common operations.
here's the complete link of the documentation
https://developer.android.com/training/articles/memory.html
UPDATE
After working excrutiatingly with out of memory errors
i would say adding this to the manifest to avoid the oom issue is not a sin, also like @Milad points out below it does not affect the normal working of the app
UPDATE 2
Here are a few tips to deal with out of memory errors
1) Use these callback that android gives onLowMemory
, onTrimMemory(int)
and clear the cache of image like (picasso, glide, fresco....) you can read more about them here and here
2) compress your files(images, pdf)
3) read about how to handle bitmap more efficiently here
4) Use lint regularly before production pushes to ensure code is sleek and
not bulky
What are the downsides of using android:largeHeap= true ?
From my understanding, all it will really do is allow your application a higher memory limit - the largeHeap size differs between devices though, so you're not guaranteed a particular amount of extra memory. We use it at my job for one of our applications since it will be the only application running on the device.
javaMaxHeapSize vs android:largeHeap
JavaMaxHeapSize: the heap size for the dex process, It is for speeding up the build gradle
LargeHeap: Most apps should not need this and should instead focus on reducing their overall memory usage for improved performance. Enabling this also does not guarantee a fixed increase in available memory, because some devices are constrained by their total available memory. It is for allocating more memory to run application on RAM.
JavaMaxHeapSize: https://hackernoon.com/speed-up-gradle-build-in-android-studio-80a5f74ac9ed
LargeHeap:https://developer.android.com/guide/topics/manifest/application-element.html
Is there an alternative to android:largeHeap= true
Is using largeheap in Android manifest a good practice?
That being said I've just checked the docs and there's no thing such as deprecated
label or warning.
If your app makes hevy usage of memory, and you don't want to request a larger heap from Dalvik
optimize your app.
Quote from @Gabe
Use LRUCaches and lazy loading techniques to minimize the number of
images in memory.
Checkout also this official reference.
Related Topics
Background Service with Location Listener in Android
Slowing Speed of Viewpager Controller in Android
How to Get the Height and Width of the Android Navigation Bar Programmatically
Android Fragment Onattach() Deprecated
"Gradle Version 2.10 Is Required." Error
Reference One String from Another String in Strings.Xml
Get Referrer After Installing App from Android Market
Android Popup Window Dismissal
Play Audio File from the Assets Directory
How to Show Dependencies Tree in Android Studio
Custom Filtering in Android Using Arrayadapter
Error:(6, 0) Gradle Dsl Method Not Found: 'Google()'
Android Camera Preview Stretched
Importing Google-Play-Service Library Showing a Red X Next to This Reference Android
An Established Connection Was Aborted by the Software in Your Host MAChine