The bitmap issue on the Droid is really about whether you want to show more
graphics at smaller size, or the same graphics at larger size.

I don't know what you app does, but imagine that it's a 2d game, where the
graphics are re-used a lot (land tiles, character icons, etc.).

If you let the higher resolution screen show more of the game map at a time,
your program will consume NEARLY identical memory to what it would on other
devices. Why? Because the tiles will be the same size in memory; the only
thing that would be larger would be the screen surface, and any back buffers
you use.

On the other hand, if you want the graphics on the Droid to look the same
(same game play area visible), then without work, your application will take
more memory on the Droid. Why? Because unless you explicitly avoid it,
Android will scale your image up to higher resolution when you load them, so
they take more memory.

The solutions are to:
1) Create high-density images that are simply smaller, but occupy the same
number of pixels. This way, loading resources on the denser devices won't
take any memory, or
2) Resize the images after you load them, understanding that loading the
exact same resource on two different devices may result in two different
sized bitmaps in memory

Of course approach #1 is the standard solution.

I hope I am being clear. In short, if you want higher quality graphics, of
course they will take more memory. If you want the same exact graphics
(which will appear smaller on the denser screen), then you must do the work
to make that happen, as it sounds like you are not now, so Android is
scaling them up.

SoftwareForMe.com
Makers of PhoneMyPC

On Wed, Dec 2, 2009 at 6:12 PM, Jason Proctor <jason.android.li...@gmail.com
> wrote:

> IMHO, if the device offers 50% more memory per application, but the
> bitmaps take up more than 50% more memory, then the net effect is a
> stricter limitation.
>
> i'm seeing some occasional OOMs only on Droid, and so i'm being extra
> careful about recycling bitmaps and all that.
>
>
> At 5:40 PM -0800 12/2/09, Romain Guy wrote:
> >The new device does not have stricter limitations since it gives apps
> >more RAM (24 MB instead of 16 MB.)
> >
> >On Wed, Dec 2, 2009 at 5:29 PM, Matt Kanninen <mathias...@gmail.com>
> wrote:
> >>  What did I do wrong?  I worked within the defined limitations, then a
> >>  new handset came out with stricter limitations.
> >>
> >>  I'm kind of confused how you can blame me!
> >>
> >>  On Dec 2, 5:19 pm, Romain Guy <romain...@android.com> wrote:
> >>>  The Droid has more pixels and a high display density, therefore
> >>>  bitmaps are scaled and require more memory. If your app is running out
> >>>  of memory, do not blame it on the framework and "poorer performance,"
> >>>  blame it on your app for doing the wrong thing and abusing the Java
> >>>  heap.
> >>>
> >>>
> >>>
> >>>  > The app worked great on the G1.  I've clearly hit a case where the
> >>>  > framework made some decisions that result in poorer performance on
> the
> >>>  > Droid.
> >>>
> >>>  > The bitmap out of memory errors can still occur on any
> setLayout(res/
> >>>  > xml/id), after running the app for 5-30 mins.  But I did fix the
> >>>  > bitmap out of memory crash that occured during
> >>>
> >>>  > glow.setBackgroundResource(glowDrawableIds[scale]);
> >>>
> >>>  > We just don't set a new background resource anymore.
> >>>
> >>>  > I had 10 animation frames, and the animation frame chosen was based
> >>>  > upon the volume coming from the mic.
> >>>
> >>>  > Now we take what was the last frame, and vary it's drawable's
> >>>  > transparency depending on volume.
> >>>
> >>>  > glow.getBackground().setAlpha(alpha);
> >>>
> >>>  > I will now start creating additional res/xml/files, so that LESS
> >>>  > complex layouts are used on the Verizon Motorola Droid with firmware
> >>>  > 2.0 then we used on the G1.
> >>>
> >>>  > The layouts, and the final resulting screens were approved by
> >>>  > management, so I will be trying hard not to change ANYTHING on the
> G1,
> >>>  > while adding support for the inferior memory handling on the only
> >>>  > Android 2.0 handset.  The one with better specs.
> >>>
> >>>  > Can anyone recommend which Android debugging tool I should be using
> to
> >>>  > figure out what to optimize?
> >>>
> >>>  > On Nov 25, 11:11 am, Streets Of Boston <flyingdutc...@gmail.com>
> >>>  > wrote:
> >>>  >> As in the comment in your bug-report by Romain, you're using too
> much
> >>>  >> memory.
> >>>  >> Note that you only have 16MByte total available RAM for your
> process,
> >>>  >> including your bitmaps.
> >>>
> >>>  >> - Only load the bitmaps that are absolutely necessary (especially
> when
> >>>  >> they become quite large).
> >>>  >> - Load the bitmaps scaled to the size of your screen, if possible.
> Use
> >>>  >> BitmapFactory.decode and set the 'inSampleSize' of your
> bitmap-options
> >  >> >> to scale down the size of the bitmap to be loaded and rendered on
> the
> >>>  >> screen.
> >>>
> >>>  >> On Nov 25, 12:46 pm, MattKanninen<mathias...@gmail.com> wrote:
> >>>
> >>>  >> > <a href="http://code.google.com/p/android/issues/detail?id=5045
> ">Issue
> >>>  >> > 5045</a>
> >>>
> >>>  >> >http://code.google.com/p/android/issues/detail?id=5045
> >>>
> >>>  >> > On Nov 25, 9:37 am, MattKanninen<mathias...@gmail.com> wrote:
> >>>
> >>>  >> > > This:
> >>>  >> > >         private static final int[] glowDrawableIds={
> >>>  >> > >                 R.drawable.graphic_microphoneglow_01,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_02,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_03,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_04,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_05,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_06,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_07,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_08,
> >  >> >> > >                 R.drawable.graphic_microphoneglow_09,
> >>>  >> > >                 R.drawable.graphic_microphoneglow_10
> >  >> >> > >         };
> >>>  >> > > ...
> >>>  >> > > View glow = findViewById(R.id.glow);
> >>>  >> > > ..
> >>>
> >>>  >> > > glow.setBackgroundResource(glowDrawableIds[scale]);
> >>>
> >>>  >> > > is causing
> >>>
> >>>  >> > > 11-25 09:21:02.046: WARN/UsageStats(1018): Failed to
> >>>persist new stats
> >>>  >> > > 11-25 09:21:02.694: DEBUG/dalvikvm(2386): GC freed 298
> >>>objects / 15656
> >>>  >> > > bytes in 61ms
> >>>  >> > > 11-25 09:21:02.952: ERROR/dalvikvm-heap(2386): 1111680-byte
> external
> >>>  >> > > allocation too large for this process.
> >>>  >> > > 11-25 09:21:02.952: ERROR/(2386): VM won't let us allocate
> 1111680
> >>>  >> > > bytes
> >>>  >> > > 11-25 09:21:02.952: DEBUG/AndroidRuntime(2386): Shutting down
> VM
> >>>  >> > > 11-25 09:21:02.952: WARN/dalvikvm(2386): threadid=3: thread
> exiting
> >>>  >> > > with uncaught exception (group=0x4001b180)
> >>>  >> > > 11-25 09:21:02.952: ERROR/AndroidRuntime(2386): Uncaught
> handler:
> >>>  >> > > thread main exiting due to uncaught exception
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):
> >>>  >> > > java.lang.OutOfMemoryError: bitmap size exceeds VM budget
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.graphics.Bitmap.nativeCreate(Native Method)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.graphics.Bitmap.createBitmap(Bitmap.java:468)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.graphics.Bitmap.createBitmap(Bitmap.java:435)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > >
> android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > >
> android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > >
> >>>android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:
> >>>  >> > > 323)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.graphics.drawable.Drawable.createFromResourceStream
> >>>  >> > > (Drawable.java:697)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.content.res.Resources.loadDrawable(Resources.java:1705)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.content.res.Resources.getDrawable(Resources.java:580)
> >>>  >> > > 11-25 09:21:03.014: ERROR/AndroidRuntime(2386):     at
> >>>  >> > > android.view.View.setBackgroundResource(View.java:7187)-
> >>>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
> android-developers@googlegroups.com
> >>>  > To unsubscribe from this group, send email to
> >>>  > 
> >>> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> >>>  > For more options, visit this group at
> >  >> >http://groups.google.com/group/android-developers?hl=en
> >>>
> >>>  --
> >>>  Romain Guy
> >>>  Android framework engineer
> >>>  romain...@android.com
> >>>
> >>>  Note: please don't send private questions to me, as I don't have time
> >>>  to provide private support.  All such questions should be posted on
> >>>  public forums, where I and others can see and answer them
> >>
> >>  --
> >>  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<android-developers%2bunsubscr...@googlegroups.com>
> >>  For more options, visit this group at
> >>  http://groups.google.com/group/android-developers?hl=en
> >>
> >
> >
> >
> >--
> >Romain Guy
> >Android framework engineer
> >romain...@android.com
> >
> >Note: please don't send private questions to me, as I don't have time
> >to provide private support.  All such questions should be posted on
> >public forums, where I and others can see and answer them
> >
> >--
> >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<android-developers%2bunsubscr...@googlegroups.com>
> >For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
>
> --
> jason.vp.engineering.particle
>
> --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> 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 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