关于解决VM heap的问题

<p>
今天弄个简单的图片显示程序</p>
LinearLayout linearLayout =(LinearLayout)this.findViewById(R.id.LinearLayout1);
        for(int i=0;i<imagePath.length;i++)
        {
        	img[i]=new ImageView(this);
        	img[i].setImageResource(imagePath[i]);
        	img[i].setPadding(5, 5, 5, 5);
        	LayoutParams layoutParams=new LayoutParams(253,148);
        	img[i].setLayoutParams(layoutParams);
        	linearLayout.addView(img[i]);
        }

在物理机运行正常,但是在模拟器运行出现下面的问题:

09-07 05:58:48.972: D/dalvikvm(1981): GC_FOR_ALLOC freed 48K, 4% free 2739K/2844K, paused 24ms, total 25ms

09-07 05:58:48.972: I/dalvikvm-heap(1981): Grow heap (frag case) to 6.412MB for 3864408-byte allocation

09-07 05:58:48.992: D/dalvikvm(1981): GC_FOR_ALLOC freed 2K, 2% free 6510K/6620K, paused 18ms, total 18ms

09-07 05:58:49.082: D/dalvikvm(1981): GC_FOR_ALLOC freed 10K, 2% free 6514K/6620K, paused 2ms, total 2ms

09-07 05:58:49.082: I/dalvikvm-heap(1981): Grow heap (frag case) to 10.098MB for 3864408-byte allocation

09-07 05:58:49.122: D/dalvikvm(1981): GC_FOR_ALLOC freed <1K, 2% free 10288K/10396K, paused 23ms, total 23ms

09-07 05:58:49.412: D/dalvikvm(1981): GC_FOR_ALLOC freed <1K, 2% free 10289K/10396K, paused 2ms, total 3ms

09-07 05:58:49.412: I/dalvikvm-heap(1981): Grow heap (frag case) to 13.785MB for 3864408-byte allocation

09-07 05:58:49.452: D/dalvikvm(1981): GC_FOR_ALLOC freed <1K, 1% free 14063K/14172K, paused 27ms, total 28ms

09-07 05:58:49.722: D/dalvikvm(1981): GC_FOR_ALLOC freed <1K, 1% free 14064K/14172K, paused 3ms, total 3ms

09-07 05:58:49.722: I/dalvikvm-heap(1981): Forcing collection of SoftReferences for 3864408-byte allocation

09-07 05:58:49.732: D/dalvikvm(1981): GC_BEFORE_OOM freed 9K, 1% free 14055K/14172K, paused 4ms, total 4ms

09-07 05:58:49.732: E/dalvikvm-heap(1981): Out of memory on a 3864408-byte allocation.

09-07 05:58:49.732: I/dalvikvm(1981): "main" prio=5 tid=1 RUNNABLE

09-07 05:58:49.732: I/dalvikvm(1981):   | group="main" sCount=0 dsCount=0 obj=0xb3d20bd8 self=0xb8e4d4c0

09-07 05:58:49.732: I/dalvikvm(1981):   | sysTid=1981 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-1216815008

09-07 05:58:49.732: I/dalvikvm(1981):   | state=R schedstat=( 0 0 0 ) utm=18 stm=1 core=0

09-07 05:58:49.732: I/dalvikvm(1981):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.content.res.Resources.loadDrawable(Resources.java:2110)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.content.res.Resources.getDrawable(Resources.java:700)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.widget.ImageView.resolveUri(ImageView.java:638)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.widget.ImageView.setImageResource(ImageView.java:367)

09-07 05:58:49.732: I/dalvikvm(1981):   at com.jwy.linearlayout.MainActivity.onCreate(MainActivity.java:24)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.Activity.performCreate(Activity.java:5231)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.ActivityThread.access$800(ActivityThread.java:135)

09-07 05:58:49.732: I/dalvikvm(1981):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

09-07 05:58:49.752: I/dalvikvm(1981):   at android.os.Handler.dispatchMessage(Handler.java:102)

09-07 05:58:49.752: I/dalvikvm(1981):   at android.os.Looper.loop(Looper.java:136)

09-07 05:58:49.752: I/dalvikvm(1981):   at android.app.ActivityThread.main(ActivityThread.java:5017)

09-07 05:58:49.752: I/dalvikvm(1981):   at java.lang.reflect.Method.invokeNative(Native Method)

09-07 05:58:49.752: I/dalvikvm(1981):   at java.lang.reflect.Method.invoke(Method.java:515)

09-07 05:58:49.752: I/dalvikvm(1981):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)

09-07 05:58:49.752: I/dalvikvm(1981):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

09-07 05:58:49.752: I/dalvikvm(1981):   at dalvik.system.NativeStart.main(Native Method)

09-07 05:58:49.752: D/skia(1981): --- decoder->decode returned false

09-07 05:58:49.752: D/AndroidRuntime(1981): Shutting down VM

09-07 05:58:49.752: W/dalvikvm(1981): threadid=1: thread exiting with uncaught exception (group=0xb3d1fb20)

09-07 05:58:49.752: E/AndroidRuntime(1981): FATAL EXCEPTION: main

09-07 05:58:49.752: E/AndroidRuntime(1981): Process: com.jwy.linearlayout, PID: 1981

09-07 05:58:49.752: E/AndroidRuntime(1981): java.lang.OutOfMemoryError

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.content.res.Resources.loadDrawable(Resources.java:2110)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.content.res.Resources.getDrawable(Resources.java:700)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.widget.ImageView.resolveUri(ImageView.java:638)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.widget.ImageView.setImageResource(ImageView.java:367)

09-07 05:58:49.752: E/AndroidRuntime(1981): at com.jwy.linearlayout.MainActivity.onCreate(MainActivity.java:24)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.Activity.performCreate(Activity.java:5231)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.ActivityThread.access$800(ActivityThread.java:135)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.os.Handler.dispatchMessage(Handler.java:102)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.os.Looper.loop(Looper.java:136)

09-07 05:58:49.752: E/AndroidRuntime(1981): at android.app.ActivityThread.main(ActivityThread.java:5017)

09-07 05:58:49.752: E/AndroidRuntime(1981): at java.lang.reflect.Method.invokeNative(Native Method)

09-07 05:58:49.752: E/AndroidRuntime(1981): at java.lang.reflect.Method.invoke(Method.java:515)

09-07 05:58:49.752: E/AndroidRuntime(1981): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)

09-07 05:58:49.752: E/AndroidRuntime(1981): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

09-07 05:58:49.752: E/AndroidRuntime(1981): at dalvik.system.NativeStart.main(Native Method)

解决方法:把编辑模拟器,将其VM Heap 值由默认的16改为128

时间: 2024-10-09 01:38:33

关于解决VM heap的问题的相关文章

解决VM安装VMTools后错误提示,实现文件共享

在VM里给Red Hat 9.0安装VMTools后重启,在系统启动过程中出现三处提示,分别为:第一处:Mounting local filesystem: Error: Cannot mount filesystem: Protocol error      [FAILED] 第二处:Starting vmware-tools: Starting VMware Tools services in the virtual machine:                      Switchi

Hadoop on Mac with IntelliJ IDEA - 5 解决java heap space问题

本文讲述在CentOS 6.5中提交作业到hadoop 1.2.1于reduce阶段遇到Error: java heap space错误导致作业重新计算的解决过程.解决办法适用Linux.Mac OS X 和Windows操作系统. 环境:Mac OS X 10.9.5, IntelliJ IDEA 13.1.4, Hadoop 1.2.1 Hadoop放在虚拟机中,宿主机通过SSH连接,IDE和数据文件在宿主机.IDEA自身运行于JDK 1.8,IDEA工程及Hadoop使用JDK 1.6.

openstack重启openstack-nova-nonvcproxy解决VM无法访问问题

今天我遇到一个问题是基于openstack平台VM无法打开novnc控制台,并且使用nova get-vnc-console $VM_UUID novnc获取URL,把URL粘贴到浏览器地址依然无法访问. 一开始我以为是Win7系统中的Firefox异常,然后重新安装了火狐.因为openstack 平台里面有bootstrap技术,火狐浏览器对openstack的平台支持比较好. 可是后来使用nova get-vnc-console $VM_UUID novnc发现依然无法访问.我觉得不是我浏览

解决 VM with version 2.1.0 has multidex support ; VM has multidex support, MultiDex support library is disabled.问题

发布打包完之后,android studio提示 VM with version 2.1.0 has multidex support I/MultiDex: installI/MultiDex: VM has multidex support, MultiDex support library is disabled. 解决方案:更新gradle 版本为2.1.0.

解决vm虚拟机无法打开问题

今天河北魅力网络的客户遇到虚拟机无法打开问题,提示获取所有权失败等错误提示,魅力网络深知这是由于不正常的关机导致的,要是正常的关机一般不会出现这种问题.不正常关机的情况下会出现很多很多锁定的文件,后缀为lck 为此我们删除这些文件即可,魅力网络一开始删了也是启不开,后来从新按了虚拟机软件,也可能是一开始没有删除完整 删除如下文件 魅力网络亲测已解决,朋友们有什么问题也可以联系我企鹅1632665886 不删除也可以 我是把这些文件移动到一个文件夹中 今天新安装了虚拟机软件,发现打开虚拟机文件就是

解决VM虚拟机克隆linux、无法上网问题

使用的VM10, 一般来说克隆之后,/etc/udev/rules.d/70-persistent-net.rules这个文件夹下,虚拟机会自动生成一个eth1,然而我这个并没有....导致没有查看到虚拟机分的mac地址 启动network的时候会报这个error:Device eth0 has different MAC address than expected, ignoring 这时候,你可以使用ifconfig -a查看eth0的mac,然后我们根据这个mac修改/etc/udev/r

解决VM虚拟机重启后hostname变化问题#hostname永不改变

虚拟机启动后主机名设置问题,在centos7中设置hostname后怎么都是原来的hostname,根本无效.所以在centos7中除了修改hosts文件和network文件后,还需修改etc/hostname文件,具体步骤如下    第一步:修改/etc/sysconfig/network文件    #>vi /etc/sysconfig/network    添加或修改:    NETWORKING=yes    HOSTNAME=slave    第二步:修改/etc/hosts文件   

Android基础笔记(十五)- 图形、解决大图OOM、绘画工具的使用和练习

计算机图形表示的原理 加载大图出现OOM 缩放加载大的图片资源 创建一个原图的副本 图形处理的常用的API 傻瓜版美图秀秀 画画版 计算机图形表示的原理 首先要明确的一点是,一张图片的在内存中存储所需的大小和图片在屏幕设备上完整显示所需的内存大小是有非常大的差异的. 如下图,从中我们可以清晰的看出这张图片,在硬盘上所占的存储空间是303KB,也就是310272个字节.但是如果想把这样图片完整的展示到屏幕设备上,所需的内存空间远远不止这些. 有这样一个计算公式:图片展示所需内存 = 图片的宽度像素

Android开发解决加载图片OOM问题(非常全面 兼顾4.0以下系统)(by 星空武哥)

转载请标明:http://blog.csdn.net/lsyz0021/article/details/51295402 我们项目中经常会加载图片,有时候如果加载图片过多的话,小则导致程序很卡,重则OOM导致App挂了,今天翻译https://developer.Android.com/training/displaying-bitmaps/index.html,学习Google高效加载大图片的方法. 图片有各种形状和大小,但在大多数情况下,这些图片都会大于我们程序所需要的大小.比如说系统图片库