Viktor, This question comes up in various guises. I think your problem is
explained by some old posts I made on this thread.

http://groups.google.com/group/android-developers/browse_thread/thread/ee5e49740cd54eaa/ec3614a46c5eb79f

<http://groups.google.com/group/android-developers/browse_thread/thread/ee5e49740cd54eaa/ec3614a46c5eb79f>
Tom.

On 27 August 2010 08:34, Viktor <[email protected]> wrote:

> Why wouldn't nulling b mark the array for garbage collection? What
> other pointers to the array could there be?
>
> I tried your suggestions with no success.
>
> On Aug 25, 6:23 pm, DanH <[email protected]> wrote:
> > OK, I see that you're nulling "b" between the two allocations.  But
> > that doesn't assure that all pointers to the array are destroyed.  Try
> > placing the "= new" and "= null" statements in a called method (& just
> > for grins return b from that method and assign it in your original
> > method).
> >
> > On Aug 25, 10:40 am, DanH <[email protected]> wrote:
> >
> >
> >
> > > The first array is 20 MB.  The second is also 20 MB.  What's the
> > > problem?
> >
> > > On Aug 24, 4:28 pm, Viktor <[email protected]> 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 withandroidallocating 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.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to