United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-8015334 Memory leak when kerning is used on Windows
JDK-8015334 : Memory leak when kerning is used on Windows

Details
Type:
Bug
Submit Date:
2013-05-22
Status:
Resolved
Updated Date:
2013-10-07
Project Name:
JDK
Resolved Date:
2013-06-17
Component:
client-libs
OS:
Sub-Component:
2d
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u21
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Font rendering or size calculation with kerning turned on leaks memory. (The problem does not appear on MacOS.)

REGRESSION.  Last worked in version 7u17

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program in the source code box, which essentially measures the width of a large number of strings rendered with kerning on.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
  Program completes quickly without consuming too much memory.
ACTUAL -
Memory is consumed rapidly. When run on 32-bit it will exit the JVM abruptly with an hs_err_pid-log, an example included in the error messages box below. When run on 64-bit it will  " just "  use a lot of memory.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x78aa1fd8, pid=2436, tid=4244
#
# JRE version: 7.0_21-b11
# Java VM: Java HotSpot(TM) Client VM (23.21-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [msvcr100.dll+0x1fd8]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x02c43000):  JavaThread  " AWT-EventQueue-0 "  [_thread_in_native, id=4244, stack(0x031d0000,0x03220000)]

siginfo: ExceptionCode=0xc0000005, writing address 0x00000000

Registers:
EAX=0x24000300, EBX=0x0321e8dc, ECX=0x00000001, EDX=0x00000002
ESP=0x0321e858, EBP=0x0321e860, ESI=0x03295052, EDI=0x00000000
EIP=0x78aa1fd8, EFLAGS=0x00010297

  Top of Stack: (sp=0x0321e858)
0x0321e858:   0321e9c8 00000000 0321e8c0 6d27b464
0x0321e868:   00000000 03295052 00000006 0328cf40
0x0321e878:   0321e9c8 00000000 0321e9dc 6b65726e
0x0321e888:   0321e920 03295052 0000154e 0000038d
0x0321e898:   0321e9dc 6b65726e 0321e8ac 03295044
0x0321e8a8:   0000155c 0321e9dc 6b65726e 0321e920
0x0321e8b8:   03295040 00001560 0321e948 6d28086a
0x0321e8c8:   03295052 00000000 00000003 00000000

Instructions: (pc=0x78aa1fd8)
0x78aa1fb8:   89 44 8f ec 8b 44 8e f0 89 44 8f f0 8b 44 8e f4
0x78aa1fc8:   89 44 8f f4 8b 44 8e f8 89 44 8f f8 8b 44 8e fc
0x78aa1fd8:   89 44 8f fc 8d 04 8d 00 00 00 00 03 f0 03 f8 ff
0x78aa1fe8:   24 95 f0 1f aa 78 8b ff 00 20 aa 78 08 20 aa 78


Register to memory mapping:

EAX=0x24000300 is an unallocated location in the heap
EBX=0x0321e8dc is pointing into the stack for thread: 0x02c43000
ECX=0x00000001 is an unknown value
EDX=0x00000002 is an unknown value
ESP=0x0321e858 is pointing into the stack for thread: 0x02c43000
EBP=0x0321e860 is pointing into the stack for thread: 0x02c43000
ESI=0x03295052 is an unknown value
EDI=0x00000000 is an unknown value


Stack: [0x031d0000,0x03220000],  sp=0x0321e858,  free space=314k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [msvcr100.dll+0x1fd8]
C  [fontmanager.dll+0xb464]
C  [fontmanager.dll+0x1086a]
C  [fontmanager.dll+0x1032a]
C  [fontmanager.dll+0x112b6]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  sun.font.SunLayoutEngine.nativeLayout(Lsun/font/Font2D;Lsun/font/FontStrike;[FII[CIIIIIIILjava/awt/geom/Point2D$Float;Lsun/font/GlyphLayout$GVData;JJ)V
J  sun.font.SunLayoutEngine.layout(Lsun/font/FontStrikeDesc;[FIILsun/font/TextRecord;ILjava/awt/geom/Point2D$Float;Lsun/font/GlyphLayout$GVData;)V
J  sun.font.GlyphLayout$EngineRecord.layout()V
J  sun.font.GlyphLayout.layout(Ljava/awt/Font;Ljava/awt/font/FontRenderContext;[CIIILsun/font/StandardGlyphVector;)Lsun/font/StandardGlyphVector;
J  sun.font.ExtendedTextSourceLabel.createGV()Lsun/font/StandardGlyphVector;
J  sun.font.ExtendedTextSourceLabel.getAdvance()F
J  java.awt.font.TextLine.init()V
J  java.awt.font.TextLine.<init>(Ljava/awt/font/FontRenderContext;[Lsun/font/TextLineComponent;[F[CII[I[BZ)V
J  java.awt.font.TextLine.fastCreateTextLine(Ljava/awt/font/FontRenderContext;[CLjava/awt/Font;Lsun/font/CoreMetrics;Ljava/util/Map;)Ljava/awt/font/TextLine;
J  java.awt.font.TextLayout.fastInit([CLjava/awt/Font;Ljava/util/Map;Ljava/awt/font/FontRenderContext;)V
J  java.awt.font.TextLayout.<init>(Ljava/lang/String;Ljava/awt/Font;Ljava/awt/font/FontRenderContext;)V
J  sun.font.FontDesignMetrics.stringWidth(Ljava/lang/String;)I
J  sun.swing.SwingUtilities2.stringWidth(Ljavax/swing/JComponent;Ljava/awt/FontMetrics;Ljava/lang/String;)I
J  com.mercur.bug.KerningLeak.leak()V
j  com.mercur.bug.KerningLeak.access$000()V+0
j  com.mercur.bug.KerningLeak$1.run()V+0
j  java.awt.event.InvocationEvent.dispatch()V+47
j  java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21
j  java.awt.EventQueue.access$200(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j  java.awt.EventQueue$3.run()Ljava/lang/Void;+12
j  java.awt.EventQueue$3.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+0
j  java.security.ProtectionDomain$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+28
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+46
j  java.awt.EventDispatchThread.pumpOneEventForFilters(I)V+245
j  java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00968800 JavaThread  " DestroyJavaVM "  [_thread_blocked, id=4116, stack(0x00a60000,0x00ab0000)]
=>0x02c43000 JavaThread  " AWT-EventQueue-0 "  [_thread_in_native, id=4244, stack(0x031d0000,0x03220000)]
  0x02c41400 JavaThread  " AWT-Windows "  daemon [_thread_in_native, id=3216, stack(0x030e0000,0x03130000)]
  0x02c3fc00 JavaThread  " AWT-Shutdown "  [_thread_blocked, id=3120, stack(0x03090000,0x030e0000)]
  0x02c3ec00 JavaThread  " Java2D Disposer "  daemon [_thread_blocked, id=1732, stack(0x03040000,0x03090000)]
  0x02c0c000 JavaThread  " Service Thread "  daemon [_thread_blocked, id=2708, stack(0x02fa0000,0x02ff0000)]
  0x02c06400 JavaThread  " C1 CompilerThread0 "  daemon [_thread_blocked, id=2816, stack(0x02f50000,0x02fa0000)]
  0x02c04800 JavaThread  " Attach Listener "  daemon [_thread_blocked, id=4284, stack(0x02f00000,0x02f50000)]
  0x02c03000 JavaThread  " Signal Dispatcher "  daemon [_thread_blocked, id=3152, stack(0x02eb0000,0x02f00000)]
  0x02bf1400 JavaThread  " Finalizer "  daemon [_thread_blocked, id=3224, stack(0x02e60000,0x02eb0000)]
  0x02bef800 JavaThread  " Reference Handler "  daemon [_thread_blocked, id=4484, stack(0x02e10000,0x02e60000)]

Other Threads:
  0x02bee000 VMThread [stack: 0x02dc0000,0x02e10000] [id=3484]
  0x02c1e800 WatcherThread [stack: 0x02ff0000,0x03040000] [id=5048]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 4928K, used 3972K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K,  89% used [0x22b50000, 0x22f310d0, 0x22fa0000)
  from space 512K,   0% used [0x23020000, 0x23020120, 0x230a0000)
  to   space 512K,   0% used [0x22fa0000, 0x22fa0000, 0x23020000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)

Card table byte_map: [0x02c60000,0x02d10000] byte_map_base: 0x02b4a580

Polling page: 0x00ab0000

Code Cache  [0x00ae0000, 0x00c00000, 0x02ae0000)
 total_blobs=627 nmethods=435 adapters=127 free_code_cache=31624Kb largest_free_block=32383360

Compilation events (10 events):
Event: 1.001 Thread 0x02c06400    2 %           com.mercur.bug.KerningLeak::leak @ 105 (171 bytes)
Event: 1.002 Thread 0x02c06400 nmethod 2% 0x00bf9ac8 code [0x00bf9d20, 0x00bfa76c]
Event: 3.353 Thread 0x02c06400  430             java.awt.geom.Point2D$Float::<init> (15 bytes)
Event: 3.354 Thread 0x02c06400 nmethod 430 0x00bfb108 code [0x00bfb200, 0x00bfb280]
Event: 3.354 Thread 0x02c06400  431             sun.font.FileFontStrike::adjustPoint (18 bytes)
Event: 3.354 Thread 0x02c06400 nmethod 431 0x00bfb2c8 code [0x00bfb3d0, 0x00bfb47c]
Event: 3.357 Thread 0x02c06400  432             sun.nio.cs.SingleByte$Encoder::encodeArrayLoop (236 bytes)
Event: 3.358 Thread 0x02c06400 nmethod 432 0x00bfb508 code [0x00bfb820, 0x00bfc40c]
Event: 6.750 Thread 0x02c06400  433             java.lang.AbstractStringBuilder::expandCapacity (50 bytes)
Event: 6.750 Thread 0x02c06400 nmethod 433 0x00bfda08 code [0x00bfdb20, 0x00bfdd58]

GC Heap History (10 events):
Event: 8.601 GC heap before
{Heap before GC invocations=54 (full 0):
 def new generation   total 4928K, used 4416K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K, 100% used [0x22b50000, 0x22fa0000, 0x22fa0000)
  from space 512K,   0% used [0x22fa0000, 0x22fa0078, 0x23020000)
  to   space 512K,   0% used [0x23020000, 0x23020000, 0x230a0000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
Event: 8.601 GC heap after
Heap after GC invocations=55 (full 0):
 def new generation   total 4928K, used 0K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K,   0% used [0x22b50000, 0x22b50000, 0x22fa0000)
  from space 512K,   0% used [0x23020000, 0x23020238, 0x230a0000)
  to   space 512K,   0% used [0x22fa0000, 0x22fa0000, 0x23020000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
}
Event: 8.758 GC heap before
{Heap before GC invocations=55 (full 0):
 def new generation   total 4928K, used 4416K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K, 100% used [0x22b50000, 0x22fa0000, 0x22fa0000)
  from space 512K,   0% used [0x23020000, 0x23020238, 0x230a0000)
  to   space 512K,   0% used [0x22fa0000, 0x22fa0000, 0x23020000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
Event: 8.759 GC heap after
Heap after GC invocations=56 (full 0):
 def new generation   total 4928K, used 0K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K,   0% used [0x22b50000, 0x22b50000, 0x22fa0000)
  from space 512K,   0% used [0x22fa0000, 0x22fa0018, 0x23020000)
  to   space 512K,   0% used [0x23020000, 0x23020000, 0x230a0000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
}
Event: 8.917 GC heap before
{Heap before GC invocations=56 (full 0):
 def new generation   total 4928K, used 4416K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K, 100% used [0x22b50000, 0x22fa0000, 0x22fa0000)
  from space 512K,   0% used [0x22fa0000, 0x22fa0018, 0x23020000)
  to   space 512K,   0% used [0x23020000, 0x23020000, 0x230a0000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
Event: 8.917 GC heap after
Heap after GC invocations=57 (full 0):
 def new generation   total 4928K, used 0K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K,   0% used [0x22b50000, 0x22b50000, 0x22fa0000)
  from space 512K,   0% used [0x23020000, 0x23020140, 0x230a0000)
  to   space 512K,   0% used [0x22fa0000, 0x22fa0000, 0x23020000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
}
Event: 9.074 GC heap before
{Heap before GC invocations=57 (full 0):
 def new generation   total 4928K, used 4416K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K, 100% used [0x22b50000, 0x22fa0000, 0x22fa0000)
  from space 512K,   0% used [0x23020000, 0x23020140, 0x230a0000)
  to   space 512K,   0% used [0x22fa0000, 0x22fa0000, 0x23020000)
 tenured generation   total 10944K, used 1543K [0x280a0000, 0x28b50000, 0x32b50000)
   the space 10944K,  14% used [0x280a0000, 0x28221fc8, 0x28222000, 0x28b50000)
 compacting perm gen  total 12288K, used 716K [0x32b50000, 0x33750000, 0x36b50000)
   the space 12288K,   5% used [0x32b50000, 0x32c03098, 0x32c03200, 0x33750000)
    ro space 10240K,  42% used [0x36b50000, 0x36f922a0, 0x36f92400, 0x37550000)
    rw space 12288K,  54% used [0x37550000, 0x37bd3250, 0x37bd3400, 0x38150000)
Event: 9.075 GC heap after
Heap after GC invocations=58 (full 0):
 def new generation   total 4928K, used 0K [0x22b50000, 0x230a0000, 0x280a0000)
  eden space 4416K,   0% used [0x22b50000, 0x22b50000, 0x22fa0000)
  from space 512K,   0% used [0x22fa0000, 0x22fa0128, 0x23020000)
  to   space 512K,   0% used [0x23020000, 0x23020000, 0x23


( This report has more than 16,000 characters and has been truncated. )
                                    

Comments
This needs engineering justification and then SQE-OK before I can approve.
                                     
2013-06-20
I do not see why this bug has keyword 7u40-critical-request because it's backport JDK-8017213 already has it
                                     
2013-06-24
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/c636942a28ef
User:  lana
Date:  2013-06-24 22:17:17 +0000

                                     
2013-06-24
Per Pavel's comments - if appropriate - please remove the 7u40-critical-request - if this is already approved in a different bug ID.
                                     
2013-06-25
package com.mercur.bug;

import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.font.TextAttribute;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

public class KerningLeak {

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                leak();
            }
        });
    }
    
    private static void leak() {
        Map&lt;TextAttribute, Object&gt; textAttributes = new HashMap&lt;&gt;();
        textAttributes.put(TextAttribute.FAMILY, "Sans Serif");
        textAttributes.put(TextAttribute.SIZE, 12);
        textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
        Font font = Font.getFont(textAttributes);
        JLabel label = new JLabel();
        int dummy = 0;
        for (int i = 0; i &lt; 1000; i++) {
            System.out.println("Starting iter " + (i+1));
            for (int j = 0; j &lt; 1000; j++) {
                FontMetrics fm = label.getFontMetrics(font);
                dummy += SwingUtilities.computeStringWidth(fm, Integer.toString(j));
            }
        }
        System.out.println("done " + dummy);
    }
}
                                     
2013-05-23
The constructor for KernTable no longer checks to see if the font already
has a copy of the kern pairs, so each time it stores a new table.
                                     
2013-06-12
URL:   http://hg.openjdk.java.net/jdk8/2d/jdk/rev/c636942a28ef
User:  prr
Date:  2013-06-17 17:39:11 +0000

                                     
2013-06-17



Hardware and Software, Engineered to Work Together