bitmap size exceeds VM budget

we can avoid this error by the following parts:
1  its not how much images the screen has, but being carefull on cleaning everything up when finishing the activity 
2   Technique to Avoid, #3: Going Overboard with Layouts:
Due to changes in the View rendering infrastructure, unreasonably deep (more than 10 or so) or broad (more than 30 total) View hierarchies in layouts are now likely to cause crashes. This was always a risk for excessively complex layouts, but you can think of Android 1.5 as being better than 1.1 at exposing this problem. Most developers won't need to worry about this, but if your app has very complicated layouts, you'll need to put it on a diet. You can simplify your layouts using the more advanced layout classes like FrameLayout and TableLayout.

If your application  involve many images,(some times may be seldom.),if causing this error,you can check the following aspects:

1 .   Is your "Bitmap" object  released before the "Activity"  finished which it's belonged ?
         you can use "recycle()","System.gc()", if a  arraylist,you can use "clear()"  ,do it  before your activity finished.
         for example:

try{                  
      Intent myintent=new Intent();
      Bundle bun=new Bundle();
      bun.putInt("position", position);
      myintent.putExtras(bun);
      setResult(RESULT_OK,myintent);          
      imageAdapter.bitmaplist.clear();
      System.gc();
      thisActivity.finish();
      }
      catch (OutOfMemoryError e) {
          e.printStackTrace();
      }

2. You can consider to reduce the  qulity of the image .Although is not a good idea.

BitmapFactory.Options opts=new BitmapFactory.Options();
                    opts.inSampleSize =2; //the value you can set bigger than 1.
                    Bitmap imgBitmap=null;
                    imgBitmap = BitmapFactory.decodeStream(fs, null, opts);

3. Make pictures smaller.when you generate the picture ,you can do :

Bitmap bitmap = Bitmap.createScaledBitmap(cacheBitmap,330, 300, false);   

4. Definition your software' memory size,we can use this class: dalvik.system.VMRuntime

private final static int CWJ_HEAP_SIZE = 6* 1024* 1024 ;

when using:

VMRuntime.getRuntime().setMinimumHeapSize(CWJ_HEAP_SIZE); //here,set 6MB

5. make the Dalvik virtual machine optimized on heap memory allocation.

private final static float TARGET_HEAP_UTILIZATION = 0.75f;

when using:

VMRuntime.getRuntime().setTargetHeapUtilization(TARGET_HEAP_UTILIZATION);

6. Don't forget.. make the debug more convenient

try {
    
        ……
    
    } catch (OutOfMemoryError e) {
    
        e.printStackTrace();
    
    }

Ok ,that's all.

bitmap size exceeds VM budget的更多相关文章

  1. java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法

    1 BitmapFactory.decodeFile(imageFile); 用BitmapFactory解码一张图片时,有时会遇到该错误.这往往是由于图片过大造成的.要想正常使用,则需要分配更少的内 ...

  2. android报错及解决1--Bitmap加载时,报bitmap size exceeds VM budget

    报错描述: 用Bitmap加载图片资源时,报错java.lang.OutOfMemoryError: bitmap size exceeds VM budget 原因分析: android系统限制,只 ...

  3. 【Android】Bitmap加载图片错误 java.lang.OutOfMemoryError: bitmap size exceeds VM budget

    今天测试程序的时候出现下面的错误日志信息,程序当场挂掉 07-09 14:11:25.434: W/System.err(4890): java.lang.OutOfMemoryError: bitm ...

  4. (转)解决 bitmap size exceeds VM budget (Out Of Memory 内存溢出)的问题

    在做图片处理的时候最常遇到的问题估计就是Out Of Memory (内存溢出)了 网上对这种问题的解决方案很多,原来无非就是压缩图片大小 本不该重复造轮子,但实际中却遇见了问题,写出来希望后来者能引 ...

  5. Android解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget(转)

    昨天遇到这个问题就是从一个输入流里调用BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri))得到一个bit ...

  6. 【android错误】bitmap size exceeds 32bits

    使用图片缩放时遇到这么个问题: java.lang.IllegalArgumentException: bitmap size exceeds 32bits 后来一行行查代码,发现原来是 scale ...

  7. [Intellij IDEA]File size exceeds configured limit(2560000). Code insight features are not available

    在使用 IDEA, 发现一个问题File size exceeds configured limit (2560000). Code insight features not available.

  8. File attachment or query results size exceeds allowable value of 1000000 bytes.

    今天早晨,收到了作业执行失败的邮件(前几天还能正常执行该作业.不知为何今天出错) 邮件显示,作业的第三个步骤报错. step3内容: msdb.dbo.sp_send_dbmail     @prof ...

  9. Intellij IDEA中file size exceeds configured limit解决

    把Hadoop源码导入IDEA中后,其中有个ClientNamenodeProtocolProtos文件代码高达82997行,IDEA直接就不把它当java类看了,报file size exceeds ...

随机推荐

  1. ASP.NET MVC 程序 报错“CS0012: 类型“System.Data.Objects.DataClasses.EntityObject”在未被引用的程序集中定义”的解决办法

    运行MVC程序,具体报错信息如下: 解决方法: 打开Web.config在assemblies下加入<add assembly="System.Data.Entity, Version ...

  2. jQuery validate基本原则

    Markup recommendations Each input has a label associated with it: The for-attribute of the label ref ...

  3. PhoneGap 在 Android 上的插件开发方法介绍

    移动应用开发已经成为软件开发的一个重要方向,但是移动开发面临的一个重要问题就是跨平台的问题.PhoneGap 作为一个多平台的软件开发框架,提供了一次编写多个平台的运行.目前已经支持多达 6 个移动平 ...

  4. Python基础教程【读书笔记】 - 2016/7/18

    希望通过博客园持续的更新,分享和记录Python基础知识到高级应用的点点滴滴! 第七波:第3章 字符串 介绍如何使用字符串格式化其他的值,并简单了解一下利用字符串的分割.联接.搜索等方法能做些什么. ...

  5. SSH_框架整合7--整个项目CODE

    一 架构 1Action类 2 配置文件 3 View页面 二  Code 1 src (1)com.atguigu.ssh.actions >EmployeeAction.java packa ...

  6. php 自带函数

    memory_get_usage()://查看当前内存使用情况单位 bytes str_repeat("liuhui", 2);//字符串重复指定次数,liuhui重复2次

  7. [Perl] Getopt 函数来接收用户参数的使用

    我们在linux常常用到一个程序需要加入参数,现在了解一下perl中的有关控制参数的函数.getopt.在linux有的参数有二种形式.一种是–help,另一种是-h.也就是-和–的分别.–表示完整参 ...

  8. [Vue]学习中遇到的疑点

    computed:计算属性,官方api上说计算属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算.但是经过测试并没有缓存.案例: computed: { now: function () { c ...

  9. GC学习笔记

    GC学习笔记 这是我公司同事的GC学习笔记,写得蛮详细的,由浅入深,循序渐进,让人一看就懂,特转到这里. 一.GC特性以及各种GC的选择 1.垃圾回收器的特性 2.对垃圾回收器的选择 2.1 连续 V ...

  10. Python 结巴分词(1)分词

    利用结巴分词来进行词频的统计,并输出到文件中. 结巴分词github地址:结巴分词 结巴分词的特点: 支持三种分词模式: 精确模式,试图将句子最精确地切开,适合文本分析: 全模式,把句子中所有的可以成 ...