English 中文(简体)
OutOfMemoryError: bitmap amount over VERS 预算:- Android[复制]
原标题:OutOfMemoryError: bitmap size exceeds VM budget :- Android [duplicate]
This question already has answers here:
Closed 10 years ago.

Possible Duplicate:
Android: Strange out of memory issue while loading an image to a Bitmap object

i am downloading images from Url and displaying them. At download time it is giving out of memory error : bitmap size exceeds VM budget. I am using drawable. Code is below:

HttpClient httpclient= new DefaultHttpClient();
HttpResponse response=(HttpResponse)httpclient.execute(httpRequest);
HttpEntity entity= response.getEntity();
BufferedHttpEntity bufHttpEntity=new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();

Bitmap bm = BitmapFactory.decodeStream(instream);
Bitmap useThisBitmap = 
Bitmap.createScaledBitmap(bm,bm.getWidth(),bm.getHeight(), true);
bm.recycle();
BitmapDrawable bt= new BitmapDrawable(useThisBitmap);
System.gc();

此处为错误:

`05-28 14:55:47.251: ERROR/AndroidRuntime(4188): 
 java.lang.OutOfMemoryError: bitmap size exceeds VM budget`
问题回答

使用decodeStream(is, outPatter, Optionss)

BitmapFactory.Options opts=new BitmapFactory.Options();
opts.inDither=false;                     //Disable Dithering mode
opts.inPurgeable=true;                   //Tell to gc that whether it needs free memory, the Bitmap can be cleared
opts.inInputShareable=true;              //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
opts.inTempStorage=new byte[32 * 1024]; 

你可以检查图像大小,然后通过适当的因素加以缩小。

见这一问题:。 处理大比图

This issue seems to have been reported several times, here and here for instance... sorry Shalini but if it s the same issue, it seems that there is no solution at all...

The only recommendations of Romain Guy is to use less memory...

因此,希望你能以不同的方式看待你。

通用公平市价是,有些安乐团的版本,特别是2.1版,完全没有像这个版本那样的问题。

我发表了一份说明,其中我非常关心资源使用问题。 我甚至删除了我使用的许多轨道图,现在这些地图是利用图形缩略语制作的。 如果没有使用这些地图,我也回收利用。 当然,我已经核实,我的记忆中我没有发现任何传闻:旧的记忆在无控制的情况下生长,它将所有时间保持在合理的价值之内。

尽管我为努力避免这一问题付出了很大努力,但我继续获得大量像2.1和2.1更新1装置那样的无情例外。 现在,我正在使用北极圈来报告坠毁事件,我看到,即便是用4兆字节的微粒,也发生这种事件,每台白盔的肥皂面积只有16千兆瓦的四倍,而事实上,这些天的大部分装置的肥力大于16千兆瓦。

我的所有轨道图都有800x480 pixels,就最糟糕的情况而言,如ARGB_8888, 可能不会各自占据1.5德国马克以上,但在仅仅占领4兆字节时试图装上1台,因此至少应该有12枚甲基溴。 我的大多数比图被装上了一半记忆的ARGB_4444,我只使用ARGB_8888,而借方图看确实很差,444444。

因此,对我来说,很显然,这些文体上有一些东西没有做罚款。 99%的坠毁事件发生在2.1天和2.1天之间,其余原因可能是其他假想的原因。

我对许多事情进行了尝试。

BitmapFactory.Options opts=new BitmapFactory.Options();
opts.inDither=false;                     //Disable Dithering mode
opts.inPurgeable=true;        
opts.inScale=8;
///after you use your images
System.gc();

这是一个实际的答案,我试图在持续时间避免这一问题。 它还解决了我的问题。

Runtime.getRuntime().gc();

要求垃圾收集员是一个好的想法。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签