Community
Participate
Working Groups
Build Identifier: 20100617-1415 Memory in the X-Server is not released after an SWT image was drawn (GC.drawImage()) onto a smaller image (scaling down) and both images and the GC were disposed after the operation. Repeating these steps leads to a huge process memory footprint. This was observed under Linux-GTK (Ubuntu 10.4). Not reproducible on Windows. Reproducible: Always Steps to Reproduce: 1. Run the attached program ImageScalingLeakTest.java 2. For each pass approx. 70k of memory is consumed 3. The attached screenshot was taken after 1800 passes
Created attachment 175761 [details] Test program to reproduce the error
Created attachment 175762 [details] Screenshot of system monitor after 1800 passes
Created attachment 175763 [details] System configuration
Works for me. I ran your snippet on my Linux machine (Fedora Core 11) and the memory did not go up like you said.
Can we do something to sort this out?
can you tell me exactly which calls is causing the leak ? If you remove this line: gc.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0, width,height); does the leak stop ?
Yes, it is gc.drawImage() that causes the leak.
Works for me, try this snippet: public static void main(String[] args) { int count = 10000; Display display = new Display(); System.out.println("Write down the memory used by this process and hit enter"); try { System.in.read(); } catch (IOException e) { } Image image = new Image(display, 3200, 2400); Image thumbnail = new Image(image.getDevice(), 320, 240); GC gc = new GC(thumbnail); long time = System.currentTimeMillis(); for (int i = 0; i < count; i++) { gc.drawImage(image, 0, 0, 3200, 2400, 0, 0, 320, 240); } System.out.println(System.currentTimeMillis() - time); gc.dispose(); image.dispose(); thumbnail.dispose(); System.gc(); System.out.println("Compare the memory used by this process now to the initial mark, does it go up if count goes up ?"); try { System.in.read(); } catch (IOException e) { } display.dispose(); } For me it starts with 8.1mb and ends with 9mb, it doesn't matter the value for count (I tested with 1 and 10000). I also check all the code, no leaks anywhere.
Here is the reading from the system monitor, before and after: Before: Virtual 514.1 MB Resident 25.4 MB Writable 10.9 MB Shared 14.6 MB XServer 1.0 kB After: Virtual 1.0 GB Resident 411.8 MB Writable 399.7 MB Shared 10.5 MB XServer 30 MB
What is the version of X server are you running ? My guess this is a bug in the X server. Silenio, do you have ubuntu 10.4 ? can you try the snippet ?
Tried the snippet on Ubuntu 10.04. Let it run around 3000 iterations. Memory usage is stable.
XServer version is 7.5+5ubuntu1 In the meantime I found the following: https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/565981 Looks somehow similar.
I can't reproduce this issue, and comment 12 points to an issue outside of SWT.