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

WebView Memory leak and Crash VM

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0.2, fx2.1
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Environment:

      Windows 7 Home 32bit w/ JDK 1.7.0_2 and JavaFX 2.0.2
      Windows XP Professtional 32bit w/ JDK 1.6.0_31 and JavaFX 2.0.2
      Windows XP Professtional 32bit w/ JDK 1.6.0_31 and JavaFX 2.1.0 Developer preview (January 23, 2012)

    • Subcomponent:
      web

      Description

      WebEngine#load and WebEngine#loadContents have memory leak problem.

      I call these method repeatedly. JVM's Private Working Set increase to over 1GB and then crash VM.
      JVM Memory (Heap and Non Heap) seems have no problems.

      I can always reproduce problem when I run below code.
      {code}
      package ex;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class Main extends Application {

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

      WebView browser;
      WebEngine engine;
      TextField urlField;
      Button loadButton;

      int i = 0;

      String[] urls = new String[] {
      "http://www.google.co.jp",
      "http://www.yahoo.co.jp",
      "http://jp.msn.com",
      "http://www.goo.ne.jp",
      "http://www.facebook.com",
      "http://twitter.com",
      "http://www.yahoo.com",
      "http://en.wikipedia.org",
      "http://www.disney.co.jp",
      "http://www.hotpepper.jp/A_30300/svcSA11.html",
      "http://tabelog.com",
      "http://www.nttdocomo.co.jp/",
      };

      @Override
      public void start(Stage stage) throws Exception {
      urlField = new TextField();
      urlField.setMinWidth(480);
      loadButton = new Button("Go");
      loadButton.setOnAction(onButtonClicked);
      HBox pane = new HBox();
      pane.getChildren().addAll(urlField, loadButton);

      browser = new WebView();
      engine = browser.getEngine();
      BorderPane parent = new BorderPane();
      parent.setCenter(browser);
      parent.setBottom(pane);

      Scene scene = new Scene(parent, 640, 480);
      stage.setScene(scene);
      stage.show();

      new Thread(new Runnable() {

      @Override
      public void run() {
      while (true) {

      Platform.runLater(new Runnable() {
      @Override
      public void run() {
      engine.load(urls[i]);
      }
      });

      try {
      Thread.sleep(5000);
      } catch (InterruptedException e) {}
      i++;
      if (i > urls.length) i = 0;
      }
      }
      }).start();
      }

      EventHandler<ActionEvent> onButtonClicked = new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
      String url = urlField.getText();
      engine.load(url);
      }

      };

      }

      {code}

        Attachments

        1. hs_err_pid3700.log
          16 kB
        2. jconsole1.png
          jconsole1.png
          105 kB
        3. jconsole2.png
          jconsole2.png
          92 kB
        4. Main.java
          2 kB
        5. stdout.txt
          250 kB

          Activity

            People

            • Assignee:
              peterz Peter Zhelezniakov (Inactive)
              Reporter:
              mshibatajfx Manabu Shibata (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: