BZ #32: [CP] massive memory leak (image loading)

Status fields:

creation_ts:2006-11-08 17:19
component:native
version:0.97
rep_platform:All
op_sys:Linux
bug_status:NEW
reporter:hendrich@informatik.uni-hamburg.de
I just built cacao-0.97 with current classpath cvs in order to track down
a memory leak in my image-viewer application [1]. When running a slideshow,
the JDKs (1.4.x, 1.5.x, 1.6.x) work fine, but jamvm+classpath slowly leak
memory until the JVM crashes. See gcc bugzilla #29420 for details.
This occurs after about 200..400 images, depending on -Xmx memory limit
and image size. All of this on Linux x86.


Unfortunately, it seems that cacao leaks even more memory than jamvm,
on the order of 20+ MBytes per image. It seems that image data is not
collected at all, and a slideshow will crash after just a few images.
No small testcase yet, but you can download the binaries and sources
of Niffler from [1]:

cacao -Xmx300m niffler.Niffler
menu -> select directory -> <select a directory with GIF/JPEG images>
menu -> slideshow -> start slideshow (linear)
... crash

Note that this happens also when thumbnails-generation, histogram,
and exif-preview are switched off: just the plain image loading
and image rendering.

Could someone please confirm that image/JNI memory is not collected
at all by cacao? If so, I don't need to bother testing again...
Anyway, I have set this to "critical" for now.



[1]
http://tams-www.informatik.uni-hamburg.de/people/alumni/hendrich/niffler/

Comment #1 by fkung@redhat.com on 2006-11-09 21:18:37

This seems to be caused by the CairoSurface object
(gnu.java.awt.peer.gtk.CairoSurface); if you add System.out.println messages to
the constructor and finalize() method, you can see that the object does not get
garbage-collected.

This does not happen with jamvm (using the most recent jamvm, I can't reproduce
any leak at all in Niffler), but unfortunately I haven't been able to backport a
recent version of Classpath into Kaffe, so I haven't tested for this bug using
that VM.  I do not suspect weak references play a role, but that's from a visual
inspection and quick testing of the relevent Classpath code - I could have
missed something.

This is also reproducable on other applications as well, not just Niffler;
however it is especially obvious in Niffler since it handles large amounts of
image data.

Comment #2 by hendrich@informatik.uni-hamburg.de on 2006-11-09 22:22:21

Confirmed. The bug seems fixed in jamvm 1.4.4 and classpath cvs

(but I can reproduce a small leak with jamvm 1.4.2 and a major leak
with cacao 0.97).

Comment #3 by twisti@complang.tuwien.ac.at on 2006-11-11 16:04:50

Here is the GNU Classpath PR:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29420

Comment #4 by twisti@complang.tuwien.ac.at on 2007-08-21 11:28:11

I have fixed a memory leak in the Boehm-GC.  Could you try again and report what
the current memory usage is?

Comment #5 by stefan@complang.tuwien.ac.at on 2008-04-11 16:35:42

I seem to have hit the same bug using http://www.statsvn.org/.

Just run it on any large-ish svn repo (cacao for example), and it will OutOfMemoryError
pretty soon.

Comment #6 by stefan@complang.tuwien.ac.at on 2012-09-04 22:16:37

Still reproducible with current cacao and classpath, although the bug mentioned in
comment #3 is supposed to have been fixed years ago. Further, it's unbelievably slow.

Not reproducible with OpenJDK.