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

WebView leaks WCImgDecoderImpl instances

    XMLWordPrintable

Details

    • web

    Description

      WebView leaks WCImgDecoderImpl instances that are often very large. The simplest example can be used to demonstrate the problem:

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class Main extends Application {

          final BorderPane borderPane = new BorderPane();
          Button button = new Button();

          @Override
          public void start(Stage primaryStage) throws Exception {
              final WebView webView = new WebView();
              webView.getEngine().load("http://www.livewirelabs.com.au");
              borderPane.setCenter(webView);

              button = new Button("Remove");
              button.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      borderPane.setCenter(new Label("Gone"));
                  }
              });
              borderPane.setBottom(button);
              primaryStage.setScene(new Scene(borderPane, 500, 600));
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }

      Push the button and use MemoryAnalyzer to identify the leaked instances.

      I am attaching MemoryAnalyzer screen shots of the issue manifesting itself in our production application. The data in these shots is from 4 WebView instances (that no longer exist in heap) loading a single page (http://www.bloomberg.com/markets/).

      https://www.evernote.com/shard/s149/sh/4d37f473-a5e4-4663-830e-5f93d9a158c9/ae2db406d1d2766e9f36c52ee4af6936

      https://www.evernote.com/shard/s149/sh/e7bb0597-e99a-4853-a151-9d21916bc0fa/776a03044248b2b9e9551791352f9865

      https://www.evernote.com/shard/s149/sh/97641ccd-ef46-40cc-a949-21618e2a4ea7/c0fc4e4a138c64b7e5c485e8411048f5

      https://www.evernote.com/shard/s149/sh/73a6da5b-6d24-443f-af73-5b0b01b3b33a/c88f025f6a1113ec3f8d60ead6d07b75


      Attachments

        Issue Links

          There are no Sub-Tasks for this issue.

          Activity

            People

              arajkumar Arunprasad Rajkumar
              cdayjfx Craig Day (Inactive)
              Votes:
              5 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: