[Kde-java] Possible KProgressTest memory leak using GCJ
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Mar 8 20:51:53 CET 2004
On Monday 08 March 2004 13:27, Richard Dale wrote:
> On Tuesday 02 March 2004 11:47, Daniel Hanlon wrote:
> > Then, for example, the KProgressTest.java example compiles with:
> >
> > gcj KProgressTest.java --main=KProgressTest -o kprogresstest -lkoalabind
> > -I<path>/qtjava/javalib -I <path>/kdejava/koala
> >
> > Whilst the resulting executable worked fine, there was clearly a problem
> > somewhere (probably in libgcj?) as when I left it running for a day or
> > so, it ended up using 300 odd MB of RAM....
>
> I've just been experimenting with running the KProgressTest example with
> both the jdk 1.3 interpreter, and compiled with gcj:
>
> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
> 17796 duke 9 0 49928 48M 34588 S 0.0 12.8 0:03 kprogress
> 1250 duke 10 0 43584 34M 31476 S 0.1 9.1 12:13 kdeinit
> 17799 duke 9 0 26752 26M 21408 S 0.0 6.9 0:02 java
>
> But neither of them seem to leak for me - I'm using gcj 3.2.2 on PowerPC:
>
> baldhead duke 1013% gcj --version
> gcj (GCC) 3.2.2 20030217 (Yellow Dog Linux 3.0 3.2.2-2a)
>
> The compiled version seems to gain a couple of Mb in the 5 mins when it
> first starts, and then settles down and the memory usage stays constant.
Thats wrong!
17796 duke 9 0 51128 49M 34596 S 0.0 13.1 0:37 kprogress
After 5 hours or so, kprogress has grown from 49.928 Mb to 51.128 Mb, which
isn't the same rate of memory leak that Daniel had - 300 Mb in 3 days is
about 4 Mb per hour. But it is a bug somewhere - I think it's something in
the gcj JNI method invocation, rather than anything to do with this koala
java code:
public void timerEvent(QTimerEvent timer) {
if (direction == fwd) {
if (Progress.progress() == Progress.totalSteps())
direction = back;
else
Progress.advance(1);
}
else {
if (Progress.progress() == 0) { /*Progress.minValue()*/
direction = fwd;
}
else
Progress.advance(-1);
}
}
}
As long as the QTimerEvent instance 'timer' is garbage collected after the
event handler, then no other java instances are being created to add to the
memory occupancy.
-- Richard
More information about the Kde-java
mailing list