Android project combat (12): a lazy and effective way to solve OOM

Original: Android project combat (12): a lazy and effective way to solve OOM

Add android:largeHeap="true" to the application node of the manifest file of the program.

Yes, just one sentence!

So what does this line of code mean?

Simply put, it is to make the APP obtain the maximum allocatable memory in order to solve the OOM problem,

However, there are two reasons for the OOM problem:

1. A certain phone has very little memory

2. Code problems, such as not handling the size of the Bitmap image

It can be said that the case of OOM is basically the second case, then you need to modify the code to see where it is not handled properly.

Therefore, using: android:largeHeap="true" for the application is only a way to solve the problem of OOM.

Therefore, for image or video applications that require too much memory, we can use largeHeap.

 

Some people say that using this line of code will have an impact on the GC, others say it won't. The blogger here is not sure, you can check it online.

 

--------------------------------------------------------------------------------------

Finally, add a sentence, it is not recommended to use.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325033893&siteId=291194637