this error occurs when i read the stream for the second time On Tue, Jun 26, 2012 at 8:15 PM, Francisco M. Marzoa Alonso < fmmar...@gmail.com> wrote:
> Greetings, > > I have had a lot of those. > > You can reduce the sampling as told by Justin, and also use less bits > per pixel: default is ARGB_8888, but you have also ARGB_4444 and > ARGB_565. You should now anyway that use of ARGB_4444 is discouraged > because it may generate a really bad quality output in some cases. I was > using it to save memory but I have found that several images, specially > those that includes gradients, looks really ugly in that mode. > > Anyway the BEST way to solve this is to make a more rational use of the > available memory. > > I used to load ALL my application bitmaps into static members of a class > at app loading, so they were available for the rest of the session. It > was not a problem on my first app version, but the app grew and I > started to have OutOfMemoryError exceptions in some devices. > > So what I do now is freeing those bitmaps that I do not need for a > while, and load those needed by demand. > > For example, if you have a game with a main menu and a "Play" button, > there is no reason to: > > a) Load game bitmaps before the user touches Play button. > b) Keep main menu bitmaps in memory after the user touches Play button. > > So my advice is to review your code and try to load/recycle bitmaps as > needed in each different application screen or state. > > Best regards, > > > > On 26/06/12 14:54, Vijay Krishnan wrote: > > Hi all, > > How to resolve the java.lang.OutOfMemoryError while calling > > BitmapFactory.decodeStream(stream). > > > > Thanks, > > vijay.k > > > > > -- > 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 > -- 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