Android heap size limit, do we still need to develop 16 MB apps?

As in the title, do I need to develop my application with a 16 MB heap size limit? The reason I ask is because I recently developed a game that works fine on my two-year-old Droid 2. But when I test my application using AVD with a heap size limit of 16 MB, I get errors in memory. Monitoring my application with DDMS shows that the total memory allocated for my game is about 20 MB. This is not a huge difference, but getting my game to work under this 16 MB limit will really hurt the visual effects.

Now, if it was in 2008, I would not even ask this question. But this is 2012, almost 4 years after the debut of G1. Is it possible to say that most phones made last year allow applications to allocate more than 16 MB of memory? Or am I really bullying myself without developing my 16 MB application?

+6
source share
2 answers

The heap limit varies depending on the resolution of the device (and possibly also on other factors). Thus, on a device with a high resolution, the heap limit can be 30 MB, and with a low resolution G1 - 16 MB. Typically, you should change your graphics accordingly, so low-resolution devices use low-resolution graphics (which takes up less space), and high-resolution devices use high-resolution graphics (which take up more space).

+6
source

Yes, we still need it, but not in every case. If you use your own code, the memory allocated with the compiler is not included in this limit. This way you can provide more memory to your main application component. and the second way is to use Texture to draw images using OpenGL.then the memory for these textures does not include limited memory.

But this technique cannot be implemented in every case.

Another important thing, you also cannot use these 30 MB. Only 30% can be used for one application.

+2
source

Source: https://habr.com/ru/post/906467/


All Articles