BufferedImage memory leak

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?

[1040 byte] By [Avruma] at [2007-11-27 10:03:10]
# 1
What happens if you create many of them?The GC can reclaim the memory when it wants to. It doesn't need to do it just because you are calling System.gc, or are waiting for a long time.Kaj
kajbja at 2007-7-13 0:38:05 > top of Java-index,Java Essentials,Java Programming...
# 2
Aye you're right. My mistake.
Avruma at 2007-7-13 0:38:05 > top of Java-index,Java Essentials,Java Programming...