[Java-gnome-developer] Pixbuf memory leak
Brought to you by:
afcowie
From: William T. <wil...@gm...> - 2011-10-19 17:02:02
|
Hi all, I've come across a memory leak with Pixbuf - whenever I construct one, lots of memory is leaked. The test below leaks ~200MB when loading a 6kb image 10,000 times. Commenting out the Pixbuf construction leads to steady memory use. This memory usage isn't reported by the JVM. I've come across this behaviour with 4.0.19 and 4.1.1. Whilst I'd love a proper solution to this, I wonder if anyone has a quick and dirty workaround for freeing up this memory? I'm doing a production run of approximately 6000 maps for a website, which grinds to a halt after 100 or so maps, using all 8GB of RAM. Thanks Will Temperley @Test public void itLeaks() throws IOException { Gtk.init(null); for (int i = 0; i < 10000; i++) { System.out.println(i); BufferedImage b = ImageIO.read(new File("/tmp/x.png")); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ImageIO.write(b, "PNG", bos); byte[] arr = bos.toByteArray(); //comment out and memory usage remains steady Pixbuf pb = new Pixbuf(arr); } } |