The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
SUGGESTED FIX
# HG changeset patch
# User igor
# Date 1254503712 25200
# Node ID baa28f16033753e7d8f9a37a93d23b882af54447
# Parent 87d59586325c7553f06cf2d36a0be72f668b36a0
6887292: memory leak in freetypeScaler.c
Reviewed-by: bae, prr
--- a/src/share/native/sun/font/freetypeScaler.c Wed May 28 20:06:09 2008 +0400
+++ b/src/share/native/sun/font/freetypeScaler.c Fri Oct 02 10:15:12 2009 -0700
@@ -102,9 +102,21 @@ Java_sun_font_FreetypeFontScaler_initIDs
}
static void freeNativeResources(JNIEnv *env, FTScalerInfo* scalerInfo) {
+ void *stream;
+
if (scalerInfo == NULL)
return;
+ //apparently Done_Face will only close the stream
+ // but will not relase the memory of stream structure.
+ // We need to free it explicitly to avoid leak.
+ //Direct access to the stream field might be not ideal solution as
+ // it is considred to be "private".
+ //Alternatively we could have stored pointer to the structure
+ // in the scalerInfo but this will increase size of the structure
+ // for no good reason
+ stream = scalerInfo->face->stream;
+
FT_Done_Face(scalerInfo->face);
FT_Done_FreeType(scalerInfo->library);
@@ -115,6 +127,10 @@ static void freeNativeResources(JNIEnv *
if (scalerInfo->fontData != NULL) {
free(scalerInfo->fontData);
}
+
+ if (stream != NULL) {
+ free(stream);
+ }
free(scalerInfo);
}
10-06-2010
EVALUATION
A fine backport.
10-06-2010
PUBLIC COMMENTS
See
http://hg.openjdk.java.net/jdk6/jdk6-gate/jdk/rev/baa28f160337