Chinaunix首页 | 论坛 | 博客
  • 博客访问: 35771
  • 博文数量: 11
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-20 17:13
文章分类

全部博文(11)

文章存档

2010年(11)

我的朋友
最近访客

分类: 嵌入式

2010-02-23 09:08:51

bitmap size exceeds VM budget如何解决!
valid 
 


 

發文: 17 
積分: 0 
於 2009-07-03 23:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
做了个图片的listView,资源从网络获取。用Bitmap填充时发现内存吃的不一般,内容一多就报:bitmap size exceeds VM budget。还有,想我这种情况有没有其他办法。 

vote up 0 vote down
reply to postreply to post
作者Re:bitmap size exceeds VM budget如何解决! [Re:valid]
qrtt1 
 


 

發文: 1011 
積分: 28 
於 2009-07-04 09:27 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
稍為 google 了一下,有可能是寫法上造成 memory leak。
如果您確定不是單一圖片就造出可用的記憶體,那麼試著依他們討論的方向解決嚕 Smile
http://www.mail-archive.com/android-developers@googlegroups.com/msg21043.html
http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html 


vote up 0 vote down
reply to postreply to post
蝸牛角上爭何事?石火光中寄此身,隨富隨貧且歡樂,不開口笑是癡人。
作者Re:bitmap size exceeds VM budget如何解决! [Re:qrtt1]
valid 
 


 

發文: 17 
積分: 0 
於 2009-07-04 22:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是的,是Bitmap占用内存引起的。这方面通常大家都是怎么处理的?一直存在疑问。现在打算想图片先下载下来,再做处理,不知可行不?

目前这种方式是存在问题的:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class ImageItem {
  private String mId;
  private String mTitle;
  private String mImageUrl;
  private Bitmap mImageBmp;
  
  public ImageItem (String id, String title, String imageUrl) {
    super();
    mId = id;
    mTitle = title;
    mImageUrl = imageUrl;
    mImageBmp = BitmapUtils.loadBitmap(mImageUrl)
 
  }
        


vote up 0 vote down
reply to postreply to post
作者Re:bitmap size exceeds VM budget如何解决! [Re:valid]
ChihHsiang 
 
沒有方向.. 

版主 

發文: 229 
積分: 0 
於 2009-07-06 12:04 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
主要問題應該會在於你的listview是怎麼處理這些資料,
如果你的圖片沒有被gc大小會一直長上去 


vote up 0 vote down
reply to postreply to post
作者Re:bitmap size exceeds VM budget如何解决! [Re:ChihHsiang]
valid 
 


 

發文: 17 
積分: 0 
於 2009-07-06 14:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
是的,heap是只增不减的,图片的大小也许还个问题。还有刚翻了下官方的blog,讲了一个“异步”处理的方法:
http://android-developers.blogspot.com/2009/05/painless-threading.html

我正在看上面文中提到的两个例子。。 


vote up 0 vote down
reply to postreply to post
阅读(1579) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~