JDK-8080371 : Memoryleak on resolution change
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u45
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-05-12
  • Updated: 2015-05-14
  • Resolved: 2015-05-13
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
(every windows platform we have tested)

this machine runs: Microsoft Windows [Version 6.1.7601] 

A DESCRIPTION OF THE PROBLEM :
When you change resolutions (which happen frequently with remote desktop / terminal server hosting) there are memory leaks.

this bug is also reported on: https://bugs.openjdk.java.net/browse/JDK-6990010
but applies for oracles jre

The memory stays in reference and can never be garbage collected, when using visualvm we see a lot of volitilebufferedimage held.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the attached program (taken from Bug ID 6209673) on Windows.
2. Maximize the application.
3. Open task manager and observe the memory being used by the Java application.
4. Open Display Properties.
5. Switch the resolution to some other resolution.
6. Observe the memory increase by between 5 and 10MB.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no memory should be lost 
ACTUAL -
memory is lost

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import java.awt.Container;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class GraphicLeak
{
    public static void main(String[] args)
    {
        JFrame frm = new JFrame("Memory leak");
        Container cp = frm.getContentPane();
cp.add( new JLabel(
            "<html>Launch Windows Task Manager<br>Maximize the size fo this window.<br>"+
            "Watch the memory consumption of this process.<br>"+
            "See that it is in a steady state.<br>"+
            "Change the resolution of the monitor that the application is running on.<br>"+
            "Repeat changing the resolution several times.<br>"+
            "Memory usage of this process appears to jump every time the resolution is changed.<br>"+
            "If repeated enough times Out-of-memory errors will occur with every reapint.<br>"+
            "</html>"), BorderLayout.CENTER );

        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frm.pack();
        frm.setVisible(true);

        while(true)
        {
            frm.repaint();
            try { Thread.sleep(100); } catch (InterruptedException e ) {}
        }
    }
}

---------- END SOURCE ----------