JDK-8072775 : Tremendous memory usage by JTextArea
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2015-02-09
  • Updated: 2015-09-29
  • Resolved: 2015-05-13
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.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b68Fixed
Description
This is a regression in JDK 8.
In the attached test case, the program consumes almost 40 times more memory on JDK 8 than on JDK 7.
Run the application on JDK 7 and JDK 8 respectively and compare the rough memory consumption, which is printed out. It can be verified by VisualVM.

On JDK 7 I get output like:
Memory before creating the text: 2979272
Memory after  creating the text: 1759008
Memory after  setting the text: 15285616
Final memory  after everything: 18265160

On JDK 8 I get output like:
Memory before creating the text: 2785728
Memory after  creating the text: 2194120
Memory after  setting the text: 616302904
Final memory  after everything: 696162136

The first big chunk of memory is allocated at java.awt.font.TextLine.getComponents().

I have a suspicion that the regression is caused by http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/aca4a67e560d although I did not verify it.

JDK 7 used is:
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)

JDK 8 used is:
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)