BufferedImage memory leak
807589
Jul 9 2007 — edited Oct 10 2008
I've been working on an app that creates large bufferedimages to display genomic datasets and so it is imperative that i reclaim memory.
I have encountered what i think is a memoryleak in the bufferedImage class.
The following snippet should be illustrative:
public static void main (String[] args)
memleak();
FactorApp app = new FactorApp();
app.setBlockOnOpen(true);
app.open();
Display.getCurrent().dispose();
public static void memleak()
//create large BufferedImage
BufferedImage bi1 = new BufferedImage(10000,10000,java.awt.image.BufferedImage.TYPE_3BYTE_BGR);
bi1.flush();
bi1 = null;
System.gc();
I realize the last 3 lines shouldn't be strictly necessary but even with them there, bi1 is never freed. I've inspected the memory used by the process and it doesn't shrink (as one would expect) after the method has exited. Ive waited several minutes just to be sure.
Am i doing something wrong?