Closed GoogleCodeExporter closed 9 years ago
Thanks for the analysis.
I still need some convincing on your workaround, though. Using weak references
is
usually a cover for sloppy programming. In this case, wrappers should be
removed
from that ArrayList when their parent components are hidden/closed, if
possible. I
will investigate.
Original comment by heue...@gmail.com
on 21 Jan 2009 at 3:26
I don't normally use weak references in my own programming, and I'm not terribly
attached to the fix we've submitted. Here's what I can say in its defense:
1. It works :)
2. The swingWrappers list in the PSwingRepaintManager is basically a cache of
live,
reachable swing wrappers that have been encountered before. Because those
semantics
(live, reachable) match weak references exactly, no other solution will work
better.
A correctly implemented alternative solution could be just as effective, but it
will
involve adding more lines of code to PSwing.
So, you'll get no killer arguments from me. As long as the fix is 100%
effective, and
released soon, I'll be happy!
Original comment by jfuerth@gmail.com
on 11 Feb 2009 at 8:20
[deleted comment]
heuermh has suggested an alternative fix that's impressive in it's elegance.
It seems possible to do away with the swingWrappers entirely, this would
completely
eliminate any references and would hence kill the possibly for a memory leak
from this
code.
He's pushing off implementing it until he can demonstrate to himself that the
change is
necessary.
Original comment by allain.lalonde
on 17 Jul 2009 at 7:40
Committing an example that attempts to demonstrate the leak. The behaviour
with or
without the fix Allain alluded to before doesn't appear any different to me.
Used
memory is not reclaimed when PSwingCanvases are removed, as might be expected.
$ commit -m "Issue 74 ; adding PSwingMemoryLeakExample to examples" .
Adding
examples/src/main/java/edu/umd/cs/piccolo/examples/pswing/PSwingMemoryLeakExampl
e.java
Transmitting file data ...
Committed revision 491.
Original comment by heue...@gmail.com
on 17 Jul 2009 at 8:38
For what it's worth, used memory is not reclaimed when PSwingCanvases are
removed
with the original patch too. Perhaps the example is flawed.
Original comment by heue...@gmail.com
on 17 Jul 2009 at 8:43
Although I think the memory leak identified above is a problem.
It's not the only one. Turns out that the memory leak exists in PCanvas, not
just
PSwingCanvas. By looking through a heap dump, I've found that the culprit is
the call
to installInputSources() in PCanvas' constructor. If you call
setEnabled(false) before
removing the canvases from the example, the finalizers get called. I'll update
the
example to confirm.
Original comment by allain.lalonde
on 17 Jul 2009 at 11:11
heuermh's elegant solution I referred to above is attached. It basically
amounts to
removing the need for tracking PSwingCanvas.SwingWrapper instances in the
PSwingRepaintManager. With this patch applied and with the changes made to the
PCanvas
in r496, the memory leak demonstration does as its supposed to decrements the
instances
of PSwingCanvas.
Original comment by allain.lalonde
on 18 Jul 2009 at 12:26
Attachments:
Committed changes, test passes in Eclipse, doesn't pass on the command line or
when
being run from Hudson. *Very stange*
Original comment by allain.lalonde
on 18 Jul 2009 at 3:27
PCanvas has a static variable CURRENT_ZCANVAS referencing the canvas created
last.
This might be an explanation for pCanvasFinalizerCount being one less than
expected
in PSwingRepaintManagerTest.java.
I am not sure if CURRENT_ZCANVAS is required but i used to set it to null.
However
this did not solve the memory leak problem completely.
Original comment by nls...@gmail.com
on 18 Jul 2009 at 10:02
Marking as fixed. Several commits were made on this issue between Allain and
myself,
so please review svn trunk.
Original comment by heue...@gmail.com
on 28 Jul 2009 at 2:31
Verifying that is was fixed in r501. By not needing to keep a reference, the
memory
leak disappears.
Original comment by allain.lalonde
on 5 Nov 2009 at 3:24
Original issue reported on code.google.com by
jfuerth@gmail.com
on 20 Jan 2009 at 10:34