开发者

OutOfMemoryError: bitmap size exceeds VM budget (not an image size issue)

I know this error occurred many times on stackoverflow, but usually it was bitmap size problem. Mine is diffrent. I have a ListView with custom adapter. Here's my getView method:

public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.cell, null);
    }
    if (position % 2 == 0) {
        convertView.setBackgroundResource(R.drawable.cell_even_bg);
    } else {
        convertView.setBackgroundResource(R.drawable.cell_odd_bg);
    }
}

Now, when I have for ex. 100 cells开发者_开发技巧 in my listView and I scroll this list for some time, finally I always get an error OutOfMemoryError: bitmap size exceeds VM budget - and in DDMS I can see that it happens while convertView.setBackgroundResource(...) is called. My drawables are 1x10px and repeated in Y-axis.


I write a test application with 100 cells to verify your issue and found it works fine (scroll for many times), without OOM error. There must be other memory leaks in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜