Caused by the 'useDrawRotatedStringWorkaround' fix.
A bit of background first. I have a servlet based real-time chart package that uses JFreeChart. Recently I have noticed that it has been leaking memory, so after doing a lot of profiling I found that the leaks appeared to be instances of AffineTransform and FontRenderContext. The allocation traces for these showed them to be created as a result of the following code in TextUtilities:
if (useDrawRotatedStringWorkaround) {
// workaround for JDC bug ID 4312117 and others...
final TextLayout tl = new TextLayout(
text, g2.getFont(), g2.getFontRenderContext()
);
tl.draw(g2, textX, textY);
}
else {
// replaces this code...
g2.drawString(text, textX, textY);
}
Edit: To make it a bit clearer, the leak was caused by the new TextLayout call.
Disabling the workaround cured the memory leak. Is this fix still relevant ? If not, maybe it would be better to default the fix to off ?
Regards
Rob Stone
Memory leak in org.jfree.text.TextUtilities
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Presumably this memory leak is happening in JDK code? Is there a bug report at Sun, and do you know what versions of the JDK are affected?
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
I guess you could say it is in the JDK. The problem is, the code trace disappears into a sun. package, so there is no way of knowing what is going on in there. I'm not sure that I can describe the problem in sufficient detail to be able to file it at Sun, I certainly wouldn't be able to produce a simple test case.
Having said this, the bug that this is a workaround for appears to have been fixed in JDK 1.2, so would it not be better to default the workaround to 'off' in JCommon ?
I'm using JDK 1.5.
Edit: I did search around the JDK bug parade looking for any mention of this type of leak - but I couldn't see any obvious candidates.
Regards
Rob Stone
Having said this, the bug that this is a workaround for appears to have been fixed in JDK 1.2, so would it not be better to default the workaround to 'off' in JCommon ?
I'm using JDK 1.5.
Edit: I did search around the JDK bug parade looking for any mention of this type of leak - but I couldn't see any obvious candidates.
Regards
Rob Stone