Android的 - 成长堆(破片为例) - 字节分配..不加载任何位图 [英] Android - Grow Heap (Frag Case) - Byte Allocation.. Not Loading any bitmaps

查看:290
本文介绍了Android的 - 成长堆(破片为例) - 字节分配..不加载任何位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这发生在距离Splash屏幕主页的应用程序加载。它发生只在设备不上模拟器:

This happens when the app loads from Splash screen to Main page. It happens only on the device not on simulator:

05-17 08:10:16.627: I/dalvikvm-heap(14021): Grow heap (frag case) to 20.580MB for     2424256-byte allocation
05-17 08:10:16.666: D/dalvikvm(14021): GC_FOR_ALLOC freed 1K, 3% free 21000K/21511K, paused 21ms
05-17 08:10:16.697: D/dalvikvm(14021): GC_CONCURRENT freed 116K, 3% free 20885K/21511K, paused 2ms+2ms
05-17 08:10:16.720: D/dalvikvm(14021): GC_FOR_ALLOC freed 44K, 4% free 20841K/21511K, paused 10ms
05-17 08:10:16.728: I/dalvikvm-heap(14021): Grow heap (frag case) to 24.533MB for 4310896-byte allocation

我用Ecplise MAT - 字节分配解决 - Android.Graphics.Bitmap $preloaded图片...

I used Ecplise MAT - the byte allocation resolved - Android.Graphics.Bitmap $preloaded images...

我使用的设备是谷歌Nexus Prime的Andr​​oid 4.0的

The device I am using is Google Nexus Prime, Android 4.0

有没有人遇到过同样的?任何人抛出一些专业知识......

Has anyone encountered the same? Any someone throw some expertise....

推荐答案

您可能正在试图去codeA很大位图这会导致一个内存不足例外。这意味着,你正在努力实现的超过VM预算允许的设备上每个应用程序的操作,在堆内存消耗方面(这似乎是24 MB您的设备上,可能更对你的模拟器这就是为什么它不'T发生在那里!)。

You are probably trying to decode a very big Bitmap which results in an OutOfMemory exception. It means that the operation you are trying to achieve is exceeding the VM Budget allowed for each application on your device, in terms of heap memory consumption (which appears to be 24 MB on your device, probably more on your emulator which is why it doesn't happen there!).

试着品尝你的位图由两个例如一个系数:

Try to sample your Bitmapby a factor of two for instance:

BitmapFactory.Options o = new BitmapFactory.Options();
o.inSampleSize = 2;
Bitmap b = BitmapFactory.decodeFile(pathToBitmap, o);

这篇关于Android的 - 成长堆(破片为例) - 字节分配..不加载任何位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆