Out of memory error when using ImageView to render PNGs

All your problems with Audio, Video and Images.

Out of memory error when using ImageView to render PNGs

Postby underminedsk » Wed Mar 10, 2010 4:28 pm

Hey everyone,

I am getting a sporadic out of memory error when I render a PNG to the screen using ImageView. What is frustrating is that it doesn't happen every time...just most of the time.

Here is my code for my imageview class; it's very simple:
[syntax="java"]
package com.ui;

import com.code.R;
import com.code.R.drawable;

import android.content.Context;
import android.graphics.Canvas;
import android.widget.ImageView;

public class Corners extends ImageView {

public Corners(Context ctx) {
super(ctx);
setCornersGreen();
setInvisible();
}

protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
invalidate();
}

public void setVisible() {
setAlpha(200);
}

public void setInvisible() {
setAlpha(60);
}

public void setCornersRed() {
setImageResource(R.drawable.corners_red);
}

public void setCornersGreen() {
setImageResource(R.drawable.corners_green);
}

}
[/java]

Obviously there is a memory leak somewhere...am I not doing something with garbage collection that I should be? I would think there would be an easy fix to this...

Zach
underminedsk
Developer
Developer
 
Posts: 26
Joined: Tue Mar 02, 2010 3:36 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests