JDK-8293444 : Creating ScrollPane with same content component causes memory leak
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version:
    openjfx11,openjfx17,openjfx18,openjfx19,openjfx20 openjfx11,openjfx17,openjfx18,openjfx19,openjfx20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2022-09-04
  • Updated: 2022-11-29
  • Resolved: 2022-10-04
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.
Other
openjfx20 b04Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [Version 10.0.18363.1198]
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)

A DESCRIPTION OF THE PROBLEM :
Creating ScrollPane with same content component causes memory leak until the component is removed from the scene.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Open provided ScrollPaneLeakTest.
2. Keep pressing the "test' button.
3. Invoke GC and observe the ScrollPane count in memory analyzing tools - jvisualvm or Eclipse MAT. 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
After 3. the ScrollPane count should be 1.
ACTUAL -
Aftery 3. every time the button is pressed, the ScrollPane is created, it is present in heap dump.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class ScrollPaneLeakTest
{

    public static void main( String[] args )
    {
        Application.launch( FxApp.class, args );
    }

    public static class FxApp extends Application
    {

        @Override
        public void start( final Stage primaryStage ) throws Exception
        {
            System.err.println( System.getProperty( "javafx.version" ) );
            final var testLabel = new Label( "Test label" );

            final var rootPane = new BorderPane();
            final var testButton = new Button( "test" );
            testButton.setOnAction( e -> {
                rootPane.setCenter( new ScrollPane( testLabel ) );
            } );
            rootPane.setTop( testButton );
            rootPane.setCenter( new ScrollPane( testLabel ) );
            primaryStage.setScene( new Scene( rootPane, 800, 600 ) );
            primaryStage.show();
        }

    }

}

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

CUSTOMER SUBMITTED WORKAROUND :
no workaround

FREQUENCY : always



Comments
Changeset: 337c7818 Author: Andy Goryachev <angorya@openjdk.org> Committer: Kevin Rushforth <kcr@openjdk.org> Date: 2022-10-04 18:14:23 +0000 URL: https://git.openjdk.org/jfx/commit/337c78183be84a3420691f615096b54a68ac4300
04-10-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/900 Date: 2022-09-15 17:12:14 +0000
15-09-2022

ScrollPaneSkin$2 change listener
06-09-2022

Attachment <Capture.PNG> could not be scanned. The system has removed attachment. Please check the file before attempting to upload it again
06-09-2022

Checked with attached testcase in Windows 10, Java VisualVM, <attached screenshot> Test result ======== openjfx11: Fail openjfx17: Fail openjfx18: Fail openjfx19ea11: Fail openjfx20ea2: Fail
06-09-2022