Android out of memory when assigning variables

后端 未结 3 1935
北恋
北恋 2020-12-19 11:38

So I get this:

\'01-01 20:37:34.859: E/dalvikvm-heap(19921): Out of memory on a 6471856-byte allocation.\'

When trying to assign a bunch of

3条回答
  •  旧巷少年郎
    2020-12-19 12:20

    The error clearly says that you are trying to use more memory. This directly points to the image sizes. So, you need to resize your images to use lesser memory. One which can be used for this reason is BitmapFactory.Option. Or else go with manually resizing your images take care that it suit all your needs. Just for the sake of explaining things,

    Heap size is the amount of memory allocated to an application to execute. The heap size for android applications are determined by the device RAM. For example if the device has RAM of 179 MB, the android applications will only get the heap size of 18MB.

    Find about it more here. more on how to Load Large Bitmaps Efficiently is found here.

    I have a Galaxy S2 and it runs fine, but on the S3 and other phones it crashes

    Checkout the RAM size of devices you mentioned.

提交回复
热议问题