Re: [android-developers] Re: Doubt about heap size
Thanks a lot,
I thought that something like that may be happening.
But I have not very clear yet how this memory assigment works, due to
the DDMS feedback: when my app runs on the 2.1 emulator it shows 3M of
available heap space. In a given moment I have ~75% of that heap memory
allocated. Assuming it should grew dynamically, it is expected that when
I try to load a bitmap that does not fit on the 25% free heap memory, it
should grew to some more than 3M and load the bitmap within the new heap
available space. But instead of doing that, it crashes with an Out of
memory exception. The bitmap is just 800x480 pixels, that with four
bytes per colour (including one for alpha) should occupy less than 1,5M
in RAM.
I have managed to solve these problems -at least for now- making a more
intelligent use of the heap, recycling bitmaps sometimes when they are
not needed for a long period, and loading them again from assets or
resources when needed. But I am still curious about this behaviour
because it may be a real problem for me further, in this app or in other
one.
Best regards,
On 24/06/12 16:28, Streets Of Boston wrote:
> Don't mistake *maximum *heap for *available *heap.
>
> A process can have free memory in its allocated heap. This is available
> heap.
>
> A process' currently allocated heap space is equal or *less *than the
> maximum. When needed, the process can get some extra heap space until its
> maximum has been reached.
>
> On Sunday, June 24, 2012 5:56:08 AM UTC-4, Fran wrote:
>> Hi there,
>>
>> I have read that the maximum heap available for an app is 16M, despite
>> that there may be higher on newer devices.
>>
>> Anyway on a 2.1 emulator with Eclipse/DDMS my available heap shown is
>> just about 3M, while in my SGS2 real device shows about 5M of available
>> heap. As you see, a lot of lower than 16M.
>>
>> My app runs fine on my SGS2, but it crashes complaining about not having
>> sufficient heap memory on the emulator, and I have received a few
>> reports with the same error on Google Play.
>>
>> I am currently doing an effort to decrease heap consumption, but I
>> wonder why DDMS shows values so low and if some devices may actually
>> have less than 16M of heap memory.
>>
>> My app is developed for Android 2.1+
>>
>> Best regards,
>>
>>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home