problems with bitmaps

by petunio » Fri, 10 Apr 2009 04:57:42 GMT


Sponsored Links
 Hi everybody

I am having a problem with the BitmapFactory:

this is my function, that reads a stream, and returns a bitmap:

        static Bitmap getBitmap(InputStream is) throws IOException
        {
           Bitmap bmp=null;

          //do some stuff...

           bmp=BitmapFactory.decodeStream(is);

           return bmp;
        }

after calling it a few times, it crashes giving me the following
error:

ERROR/(1329): VM won't let us allocate 215488 bytes
ERROR/AndroidRuntime(1329): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget


I am counting the memory used so far, and it's only 395328 bytes, so I
am sure there must be something else...

any ideas?

Thanks


--~--~---------~--~----~------------~-------~--~----~



problems with bitmaps

by jj » Fri, 10 Apr 2009 04:58:43 GMT


 Hi everybody

I am having a problem with the BitmapFactory:

this is my function, that reads a stream, and returns a bitmap:

        static Bitmap getBitmap(InputStream is) throws IOException
        {
           Bitmap bmp=null;

          //do some stuff...

           bmp=BitmapFactory.decodeStream(is);

           return bmp;
        }

after calling it a few times, it crashes giving me the following
error:

ERROR/(1329): VM won't let us allocate 215488 bytes
ERROR/AndroidRuntime(1329): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget


I am counting the memory used so far, and it's only 395328 bytes, so I
am sure there must be something else...

any ideas?

Thanks


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


problems with bitmaps

by mark . kahrl » Fri, 10 Apr 2009 07:37:02 GMT


 There's been a number of threads on this issue, the BitmapFactory
tends to throw this out of memory errors when it really shouldn't,
looks like a bug or memory leak. I'm not sure if it's cataloged as an
official bug though. Using bitmap.recycle(), and reducing the sample
size will mitigate , but not eliminate the problem. Also try reducing
the memory footprint of your images if possible. Hopefully this will
be recognized as a bug and fixed in a future release, at least I hope
so, I've had similar problems myself, and so have a number of other
developers.

                                            M



--~--~---------~--~----~------------~-------~--~----~



problems with bitmaps

by Romain Guy » Fri, 10 Apr 2009 07:44:09 GMT


 BitmapFactory does not leak. It throws an OutOfMemoryException when
there's no more memory available. That's all.







-- 
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

--~--~---------~--~----~------------~-------~--~----~



problems with bitmaps

by Mark Murphy » Fri, 10 Apr 2009 07:53:12 GMT


 


If you have a reproducible test case, head over to  http://b.android.com 
and make it official.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



problems with bitmaps

by Win Myo Htet » Mon, 27 Apr 2009 09:46:11 GMT


 I also get the OOME ( 6291456-byte) with bitmap file of 350KB (if it is
35KB, it is fine) when I do the rotation on the third time. I use
Bitmap.createScaledBitmap so that the pic fit into the screen and I also try
do myPic.recycle() in onSaveInstanceState to release the memory but it is
not helping. I wonder if I need to do myPic.compress instead of
Bitmap.createScaledBitmap and if I am not doing the proper myPic.recycle().






--~--~---------~--~----~------------~-------~--~----~



problems with bitmaps

by Jon Webb » Wed, 29 Apr 2009 01:38:32 GMT


 I didn't see an answer to your question. You should always recycle
your bitmaps when you're done with them.
     bmp.recycle();
That said, bitmaps do take up a lot of memory, and of course it has to
be contiguous, so you must be careful using them. E.g., use System.gc
() judiciously, etc.

-- Jon Webb




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Regarding OPUSH

Hi All,
Eclair support OPUSH profile, but this package is not part of public eclair.
When these package will be on public eclair.

Thanks and Regards
Bheemsen

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Error in developing videoplayer

hi ..
     i had an error in video player while executing it
(Eclipse...galilio)
          the error is..R.id can not be resolved.....
(i.e)
"id" class s not automatically generated in R.java file.......

i get that code from the link...http://davanum.wordpress.com/
2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-
remote-urls/


Plz send ur suggestions or send the right code to my mail.......

-- 

3. Reg: Animation at same time in a service and an activity causes flicker

4. Txs to bos lucky

5. Attach Email

6. about how to detect the usb device in Android

7. Play Video via "VideoView" from source file though the emulator