Is using largeheap in Android manifest a good practice?

前端 未结 2 523
不思量自难忘°
不思量自难忘° 2020-12-17 22:37

I am developing in NDK. It hangs in Galaxy S3. For testing I put android:largeheap = \"true\" in Manifest. Then there was

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 23:11

    Personally I would say it doesn't really fall into the category of either 'good/bad practice' when used correctly.

    According to the docs:

    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.

    If you have done everything in your power to reduce memory usage, and still require it, then it isn't a bad thing to use it.

    If your app is hanging, you will need to directly address that - the largeHeap isn't a magic wand that will make problems go away for all devices. This point is made clear from the following extract of the Android Training docs:

    [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. - (source)

    I should also add that Google will not reject your app for using it.

提交回复
热议问题