The first array is 20 MB.  The second is also 20 MB.  What's the
problem?

On Aug 24, 4:28 pm, Viktor <vilainpe...@gmail.com> wrote:
> I'm having some trouble understanding why this code
>
> public class BitmapAllocTest extends Activity {
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         byte[] b = new byte[20 * 1000 * 1000];
>         b = null;
>         Bitmap.createBitmap(2500, 2000, Bitmap.Config.ARGB_8888);
>     }}
>
> throws an OutOfMemory exception on a device with a 24mb heap limit. If
> I comment out either of the allocations it runs fine. I was under the
> impression that the java vm would try to garbage collect before
> throwing OutOfMemory exceptions.
>
> I suspect it having to do with android allocating the bitmaps on the
> native heap.
>
> PS. This is a clone from my stackoverflow 
> questionhttp://stackoverflow.com/questions/3546635/android-bitmap-allocation-...
> which hasn't gotten a satisfactory answer yet.

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to