image - Android Fatal Signal 11 from XML -


i creating android app , have yet run out of memory until now. part confusing not way expect run out of memory.

i added new linear layout layout xml file. had background of image 40kb large. other images loaded approximately 12kb background being larger @ 120kb. when image loaded receive fatal signal 11 on runtime. if removed background layout work fine. changed image smaller, (2000x600) before 14kb. works fine. clear 26kb causing problem...

what kind of precautions should take ensure doesn't happen again. quality images , 2000x600 might excessive it's app phone guidelines should follow?

is there memory usage cap can extended or should stay under? also, if loaded many images on scrollview cause app crash? have had many images loaded @ once have never had crash before, i'm confused error being caused little memory usage. (in todays terms @ least.)

regards,

jake

images not consume same amount of memory in ram on disk. can ram usage by:

width*height*4 (for images alpha channel) 

and

width*height*3 (for images without alpha channel) 

an android app allotted definite amount of heap space in ram, same on particular device , rom version on device. minimum 16 mb, though these days devices give more comfortable 32 mb or 64 mb. depends on device.

you out of memory exceptions (ooms) when app exceeds heap space. simple fix is: don't exceed heap space.

the best way quality images in app use density buckets , provide different sizes android can choose. ldpi screens cannot make use of high res images anyways, should supply low res on in ldpi. on other hand, hdpi devices can make use of better resolution, , if supply 1 android can use it. given higher resolution of device, more heap space allotted running of app.

another way manage memory load need, implementing lazy loading. helpful listviews , scrollviews , other adapter based view systems.

on android 3.0 , above, can request bigger heap using android:largeheap="true". however, should avoided user notice other apps of theirs being removed memory whenever app launched, , not guaranteed receive larger heap in case.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo