您的位置:首页 > 编程语言 > PHP开发

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 629 (example.testpro)

2016-10-20 09:48 399 查看

Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 629 (example.testpro)

产生原因:编写Android程序有需要加载大量图片(同次出现30张左右图片)造成的程序闪退。

错误提示:







解决方法:

原文:


The real error is Out of memory on a 23818256-byte allocation. You are attempting to allocate a ~22MB block of memory, and you do not have that much free memory available, let alone a contiguous block that large.

In this case, this is coming from a drawable resource. ~22MB would be a truly massive image, more like 2400x2400 than 1200x1200.

Your process heap size is 48MB, which is substantial, but ~22MB is almost half your heap budget.

I would recommend that you find out which drawable resource this is (looks like it might be a background of a RelativeLayout), then reduce its size and the sizes of similar images. Here, by “size” I mean total pixel count, not the on-disk size, as what matters is the decompressed size in RAM, not how big the image is on disk.

Also, this might be an issue of resource directories. For example, if you put your 1200x1200 image in res/drawable/, that effectively is synonymous with res/drawable-mdpi/. If this device happens to be an -xhdpi device, then that would explain the memory usage, as Android will try to upsample this image and double each of the dimensions.

原文链接: Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 32140

大意:

主要说明图片所占 **巨大** 内存造成的内存溢出,是程序闪退的原因


解决方法:

主要提供两种方法:


通过降低图片的像素,例如将原1200*1200的图片降低为200*200, 目的是为了降低在RAM中解压后体积。

通过适配屏幕分辨率的图片放置位置,例如1200*1200像素的图片放置在-mdpi/,而设备为 -xhdpi 分辨率,则Android会尝试上传并将它的每个纬度扩张1倍.

由于只是一个demo,我所使用所以只是简单的将所有图片在每个 drawable/ 下放置一份。

可以看到图片的要占内存大大减小



事实上如果要尝试正确匹配,应当了解不同分辨率下屏幕图片的要求,特别是在平板 与 手机端都需要兼容的情况下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐