-
Bug
-
Resolution: Fixed
-
P3
-
None
-
None
-
b94
Whilst running -Xcheck:jni to check some code I was working
onI came across a large number of warnings about local refs
from one native method :-
WARNING: JNI local refs: 1056, exceeds capacity: 1055
at sun.font.CFontManager.loadNativeFonts(Native Method)
The source of the problem is below where it accumulates
references to strings and does not free them once they
are passed on to Java code
----
for (i = 0; i < num; i++) {
NSString *fontname = [filteredFonts objectAtIndex:i];
jobject jFontName = JNFNSToJavaString(env, fontname);
jobject jFontFamilyName =
JNFNSToJavaString(env, GetFamilyNameForFontName(fontname));
JNFCallVoidMethod(env, jthis,
jm_registerFont, jFontName, jFontFamilyName);
}
--
The solution is to add this to the loop :-
(*env)->DeleteLocalRef(env, jFontName);
(*env)->DeleteLocalRef(env, jFontFamilyName);