Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8138817

JNI warnings loading fonts on MacOSX

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • None
    • client-libs
    • None
    • 2d
    • 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);

            prr Philip Race
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: