Questions about releasing off-screen image
Recently, I encounter a memory leak issue, it's caused by off-screen image. My test case is liking the following one:
Graphics canvas = getGraphics();
Image doublebuffer = createImage(960,540);
g = doublebuffer.getGraphics();
canvas.drawImage(doublebuffer, 0, 0, this);
As I know, I can call the dispose() method to release the Graphics resources allocated in the native code. But I cannot find a good way to release the Image related resources. So I refered to Graphics.java, and add finalize() and dispose() method to java.awt.Image, thus application can call Image.dispose() method just as Graphics.dispose() to release the image resources.
I'm not sure whether this is a proper method to fix the memory leak issue. Can anyone help me about this issue? Thanks in advance.