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

Memory leak when running javafx on Linux

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_91"
      Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux archlinux 4.5.1-1-ARCH #1 SMP PREEMPT Thu Apr 14 19:19:32 CEST 2016 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Running the provided source code causes a memory leak.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the code and the system memory will slowly get depleted.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package javafxtest;

      import javafx.animation.AnimationTimer;
      import javafx.application.Application;
      import javafx.geometry.Point2D;
      import javafx.scene.Scene;
      import javafx.scene.layout.Pane;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Circle;
      import javafx.stage.Stage;

      public class Main extends Application {
          private Point2D mousePosition = new Point2D(1,0);

          @Override
          public void start(Stage primaryStage) throws Exception {
              Circle c = new Circle(30);
              c.setFill(Color.RED);
              c.setTranslateX(100);
              c.setTranslateY(100);

              Pane root = new Pane();
              root.getChildren().addAll(c);
              Scene scene = new Scene(root);

              root.setOnMouseMoved(event -> {
                  mousePosition = new Point2D(event.getX(), event.getY());
              });

              AnimationTimer at = new AnimationTimer() {
                  @Override
                  public void handle(long now) {
                      Point2D playerPos = new Point2D(c.getTranslateX(), c.getTranslateY());
                      Point2D speed = playerPos.add(mousePosition.multiply(-1)).normalize();

                      c.setTranslateX(playerPos.getX()- speed.getX()/10);
                      c.setTranslateY(playerPos.getY()- speed.getY()/10);
                  }
              };

              at.start();

              primaryStage.setScene(scene);
              primaryStage.show();
          }

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

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: