Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1. #1
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default JavaFx and memory consumption

    I just made an application with java fx that cycles videos in a folder.
    I had to set the next video firing the setonendofmedia event, so they are in a cycle, but the problem is that the application loads every video at the beginning, so after a while it fills memory and crashes.
    Is there another way to cycle videos without pre-load them or a way to flush memory every while?

    This is my code :

    Java FX Code:
    package application;
    
    
    import java.io.File;
    import java.io.FilenameFilter;
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.swing.JOptionPane;
    
    import javafx.application.Platform;
    import javafx.geometry.Pos;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBoxBuilder;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaView;
    
    class SceneGenerator {    
    
    	private int xSize;
    	private int ySize;
    	
    	public SceneGenerator(int xSize,int ySize){
    		this.xSize=xSize;
    		this.ySize=ySize;
    	}
    	
      public Scene createScene() {
        final StackPane layout = new StackPane();
    
        // determine the source directory for the playlist
        final File dir = new File(System.getProperty("user.dir")+"\\video");
        if (!dir.exists() || !dir.isDirectory()) {
          JOptionPane.showMessageDialog(null,"Cannot find video source directory: " + dir);
          Platform.exit();
          System.exit(0);
          return null;
        }
    
        //inizializzo il toolkit
    
        
        // create some media players.
        final List<MediaPlayer> players = new ArrayList<MediaPlayer>();
        for (String file : dir.list(new FilenameFilter() {
          @Override public boolean accept(File dir, String name) {
            return name.endsWith(".mp4")||name.endsWith(".flv");
          }
        })) players.add(createPlayer("file:///" + (dir + "\\" + file).replace("\\", "/").replaceAll(" ", "%20")));
        if (players.isEmpty()) {
          System.out.println("No video found in " + dir);
          Platform.exit();
          System.exit(0);
          return null;
        }    
    
        // create a view to show the mediaplayers.
        final MediaView mediaView = new MediaView(players.get(0));
    
        	mediaView.setPreserveRatio(false);
        	mediaView.setFitHeight(ySize-((ySize/100)*(JavaPlayer.panelSouthYDimension+1)-JavaPlayer.pixelAdattamento));
        	mediaView.setFitWidth(xSize);
        	  
        	
        // play each audio file in turn.
        for (int i = 0; i < players.size(); i++) {
          final MediaPlayer player     = players.get(i);
          final MediaPlayer nextPlayer = players.get((i + 1) % players.size());
    
          
         
          player.setOnEndOfMedia(new Runnable() {
            @Override public void run() {
              mediaView.setMediaPlayer(nextPlayer);
              nextPlayer.seek(nextPlayer.getStartTime());
              nextPlayer.play();
            }
          });
        }
    
       
       
    
       
    
        // start playing the first track.
        mediaView.setMediaPlayer(players.get(0));
        mediaView.getMediaPlayer().play();
    
    
    
        // layout the scene.
        layout.setStyle("-fx-background-color: black; -fx-font-size: 20; -fx-padding: 0; -fx-alignment: center;");
        layout.getChildren().addAll(
          VBoxBuilder.create().spacing(10).alignment(Pos.CENTER).children(
            mediaView).build()
        );
    
        return new Scene(layout);
      }
    
      /** sets the currently playing label to the label of the new media player and updates the progress monitor. */
    
    
      /** @return a MediaPlayer for the given source which will report any errors it encounters */
      private MediaPlayer createPlayer(String aMediaSrc) {
    //    System.out.println("Creating player for: " + aMediaSrc);
        final MediaPlayer player = new MediaPlayer(new Media(aMediaSrc));
        player.setOnError(new Runnable() {
          @Override public void run() {
            System.out.println("Media error occurred: " + player.getError());
          }
        });
        return player;
      }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    I would guess it's the creation of an array of media players.
    Is there a problem with simply creating the player when you need it rather than creating them all en mass at the start?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    Hi thanks. I'm currently change my code,using java 7, and all is working good, but once a video is loaded it is never released so the memory consumption is still high. I tried using system.gc, but it seems not to be enough. Some suggestion? Thanks in advance.
    This is my code :

    Java FX Code:
    class SceneGenerator {    
    
    private int xSize;
    private int ySize;
    
    public SceneGenerator(int xSize,int ySize){
        this.xSize=xSize;
        this.ySize=ySize;
    }
    public Scene createScene() { final StackPane layout = new StackPane();
    
    // determine the source directory for the playlist
    final File dir = new File(System.getProperty("user.dir")+"\\video");
    if (!dir.exists() || !dir.isDirectory()) {
      JOptionPane.showMessageDialog(null,"Cannot find video source directory: " + dir);
      Platform.exit();
      System.exit(0);
      return null;
    }
    
    //inizializzo il toolkit
    
    
    final MediaView mediaView = new MediaView();
    
        mediaView.setPreserveRatio(false);
        mediaView.setFitHeight(ySize-((ySize/100)*(JavaPlayer.panelSouthYDimension+1)-JavaPlayer.pixelAdattamento));
        mediaView.setFitWidth(xSize);
    
    
        final int QUEUE_SIZE = 2 ; // should be enough
        final BlockingQueue<MediaPlayer> playerQueue = new ArrayBlockingQueue<>(QUEUE_SIZE);
    
    
        final Thread createPlayerThread = new Thread(new Runnable() {
            @Override
            public void run() {
                 // create some media players.
                List<String> videoFiles = new ArrayList<String>();
                for (String file : dir.list(new FilenameFilter() {
                  @Override public boolean accept(File dir, String name) {
                    return name.endsWith(".mp4")||name.endsWith(".flv");
                  }
                })) videoFiles.add("file:///" + (dir + "\\" + file).replace("\\", "/").replaceAll(" ", "%20"));
                int nextFileIndex = 0 ;
    
                while (true) {
                    System.gc();
                    MediaPlayer player = new MediaPlayer(new Media(videoFiles.get(nextFileIndex).toString())); // create
                    player.setOnEndOfMedia(new Runnable() {
                        @Override
                        public void run() {
                            final Task<MediaPlayer> nextPlayerTask = new Task<MediaPlayer>() {
                                @Override
                                public MediaPlayer call()  {
                                    try {
                                        return playerQueue.take();
                                    } catch (InterruptedException e) {
                                        JOptionPane.showMessageDialog(null, "Error in SceneGenerator() : "+e.getMessage());
                                        return null;
                                    }
                                }
                            };
                            nextPlayerTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
                                @Override
                                public void handle(WorkerStateEvent event) {
                                    MediaPlayer player = nextPlayerTask.getValue();
                                    mediaView.setMediaPlayer(player);
                                    player.play();
                                }
                            });
                            new Thread(nextPlayerTask).start();
                        }
                    });
                    try {
                        playerQueue.put(player); // this will block if the queue is full...
                    } catch (InterruptedException exc ) { // shouldn't happen...
                        exc.printStackTrace();
                        return ;
                    }
                    nextFileIndex = (nextFileIndex + 1) % videoFiles.size();
                }
            }
        });
        createPlayerThread.setDaemon(true); // won't block application exit
    
        // Layout etc
    
        createPlayerThread.start();
        // start first player. In theory, this could block, so call it before you show the stage:
        MediaPlayer firstPlayer;
        try {
            firstPlayer = playerQueue.take();
            mediaView.setMediaPlayer(firstPlayer);
            firstPlayer.play();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            JOptionPane.showMessageDialog(null, "Error in SceneGenerator() : "+e.getMessage());
        }
    
    
    
    // layout the scene.
    layout.setStyle("-fx-background-color: black; -fx-font-size: 20; -fx-padding: 0; -fx-alignment: center;");
    layout.getChildren().addAll(
      VBoxBuilder.create().spacing(10).alignment(Pos.CENTER).children(
        mediaView).build()
    );
    
    return new Scene(layout);
    }
    
    }

  4. #4
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: JavaFx and memory consumption

    Hi,

    I would try to call dispose of the media player when one video ended and then create a new media player.

    With kind regards,

    Konrad

  5. #5
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    My code is jr7, and there isn't MediaPlayer.dispose()

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,016
    Rep Power
    6

    Default Re: JavaFx and memory consumption

    Quote Originally Posted by Kyuzo View Post
    My code is jr7, and there isn't MediaPlayer.dispose()
    Yes, there is.

    MediaPlayer (JavaFX 2.2)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    try it, but not change :

    Java FX Code:
    package application;
    
    import java.io.File;
    import java.io.FilenameFilter;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.concurrent.ArrayBlockingQueue;
    import java.util.concurrent.BlockingQueue;
    
    import javax.swing.JOptionPane;
    
    import javafx.application.Platform;
    import javafx.concurrent.Task;
    import javafx.concurrent.WorkerStateEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Pos;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.media.MediaView;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.Media;
    
    
    
    class SceneGenerator {    
    
    	private int xSize;
    	private int ySize;
    	
    	public SceneGenerator(int xSize,int ySize){
    		this.xSize=xSize;
    		this.ySize=ySize;
    	}
    	
      public Scene createScene() {
        final StackPane layout = new StackPane();
    
        // determine the source directory for the playlist
        final File dir = new File(System.getProperty("user.dir")+"\\video");
        if (!dir.exists() || !dir.isDirectory()) {
          JOptionPane.showMessageDialog(null,"Cannot find video source directory: " + dir);
          Platform.exit();
          System.exit(0);
          return null;
        }
    
        //inizializzo il toolkit
    
    
        final MediaView mediaView = new MediaView();
    
        	mediaView.setPreserveRatio(false);
        	mediaView.setFitHeight(ySize-((ySize/100)*(JavaPlayer.panelSouthYDimension+1)-JavaPlayer.pixelAdattamento));
        	mediaView.setFitWidth(xSize);
        	  
          
        	final int QUEUE_SIZE = 2 ; // should be enough
        	final BlockingQueue<MediaPlayer> playerQueue = new ArrayBlockingQueue<>(QUEUE_SIZE);
    
    
        	final Thread createPlayerThread = new Thread(new Runnable() {
        	    @Override
        	    public void run() {
        	    	 // create some media players.
        	        List<String> videoFiles = new ArrayList<String>();
        	        for (String file : dir.list(new FilenameFilter() {
        	          @Override public boolean accept(File dir, String name) {
        	            return name.endsWith(".mp4")||name.endsWith(".flv");
        	          }
        	        })) videoFiles.add("file:///" + (dir + "\\" + file).replace("\\", "/").replaceAll(" ", "%20"));
        	        int nextFileIndex = 0 ;
        	        
        	
        	        while (true) {
        	        	
        	        	
        	        	System.gc();
        	        	 final MediaPlayer player = new MediaPlayer(new Media(videoFiles.get(nextFileIndex).toString())); // create
        	            player.setOnEndOfMedia(new Runnable() {
        	                @Override
        	                public void run() {
        	                	player.dispose();
        	                    final Task<MediaPlayer> nextPlayerTask = new Task<MediaPlayer>() {
        	                        @Override
        	                        public MediaPlayer call()  {
        	                            try {
        	                            	
    										return playerQueue.take();
    									} catch (InterruptedException e) {
    										JOptionPane.showMessageDialog(null, "Error in SceneGenerator() : "+e.getMessage());
    										return null;
    									}
        	                        }
        	                    };
        	                    nextPlayerTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
        	                        @Override
        	                        public void handle(WorkerStateEvent event) {
        	                            MediaPlayer player = nextPlayerTask.getValue();
        	                            mediaView.setMediaPlayer(player);
        	                            player.play();
        	                        }
        	                    });
        	                    new Thread(nextPlayerTask).start();
        	                }
        	            });
        	            try {
        	                playerQueue.put(player); // this will block if the queue is full...
        	            } catch (InterruptedException exc ) { // shouldn't happen...
        	                exc.printStackTrace();
        	                return ;
        	            }
        	            nextFileIndex = (nextFileIndex + 1) % videoFiles.size();
        	            
        	        }
        	    }
        	});
        	createPlayerThread.setDaemon(true); // won't block application exit
    
        	// Layout etc
    
        	createPlayerThread.start();
        	// start first player. In theory, this could block, so call it before you show the stage:
        	MediaPlayer firstPlayer;
    		try {
    			firstPlayer = playerQueue.take();
    			mediaView.setMediaPlayer(firstPlayer);
    	    	firstPlayer.play();
    		} catch (InterruptedException e) {
    			// TODO Auto-generated catch block
    			JOptionPane.showMessageDialog(null, "Error in SceneGenerator() : "+e.getMessage());
    		}
        
    		      
    
        // layout the scene.
        layout.setStyle("-fx-background-color: black; -fx-font-size: 20; -fx-padding: 0; -fx-alignment: center;");
        VBox vBox = new VBox();
        vBox.setAlignment(Pos.CENTER);
        vBox.getChildren().add(mediaView);
        layout.getChildren().addAll(vBox);
    
        
        
    
        return new Scene(layout);
      }
    
    
    }

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    I'm not sure your media player is ever eligible for garbage collection.
    The first one is final, and then it is live throughout that infinite loop (I think).
    I think the same applies to the others as the code burrows down through the list of files.

    Create the media player in the narrowest possible scope.

    Indeed, is that infinite loop necessary?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    Yes, the infinite loop is necessary to cycle a videos

  10. #10
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: JavaFx and memory consumption

    Hmm. In my eyes the code is really hard to read.
    Is it required to have this playerQueue? If I understood your code correctly, you could create the MediaPlayer directly when required so you would have code that disposes the old player directly when the new one is created.

    I always try to keep such creation/disposing stuff near together but maybe I am wrong and that is not possible because I missed something.

  11. #11
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    I used VisualVM to observe the behavior of the application.

    I found that the threads are never closed, but was in "wait".

    I am sending you dump the thread.
    Do you have advice?

    These are about 86 threads open one hour after starting the software.
    Attached Files Attached Files
    Last edited by Kyuzo; 05-10-2014 at 03:12 AM.

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    Yes, because your threads are all nested (as far as I can see).
    There must be a simpler way to structure this.

    I agree with kneitzel. I don't see the pint of the Queue, for example.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  13. #13
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    I Changed the code :

    Java FX Code:
    package application;
    
    import java.io.File;
    import java.io.FilenameFilter;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    
    import javax.swing.JOptionPane;
    
    import javafx.application.Platform;
    import javafx.geometry.Pos;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.media.MediaView;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.Media;
    
    
    
    class SceneGenerator {    
    
    	private int xSize;
    	private int ySize;
    	private MediaPlayer playerNew;
    
    	private int nextFileIndex = -1 ;
    	//	private static ThreadChange createPlayerThread = new ThreadChange();	
    	private List<String> videoFiles;
    	private MediaView mediaView;
    	//	private boolean first=true;
    	Runnable finale;
    
    	public SceneGenerator(int xSize,int ySize){
    		this.xSize=xSize;
    		this.ySize=ySize;
    
    		finale = new Runnable() {
    			@Override
    			public void run() {
    
    				esegui();
    
    			}
    		};
    	}
    	public Scene createScene() { 
    		final StackPane layout = new StackPane();
    
    		// determine the source directory for the playlist
    		final File dir = new File(System.getProperty("user.dir")+"\\video");
    		if (!dir.exists() || !dir.isDirectory()) {
    			JOptionPane.showMessageDialog(null,"Cannot find video source directory: " + dir);
    			Platform.exit();
    			System.exit(0);
    			return null;
    		}
    
    		//inizializzo il toolkit
    
    
    		mediaView = new MediaView();
    
    		mediaView.setPreserveRatio(false);
    		mediaView.setFitHeight(ySize-((ySize/100)*(JavaPlayer.panelSouthYDimension+1)-JavaPlayer.pixelAdattamento));
    		mediaView.setFitWidth(xSize);
    
    		videoFiles = new ArrayList<String>();
    		for (String file : dir.list(new FilenameFilter() {
    			@Override public boolean accept(File dir, String name) {
    				return name.endsWith(".mp4")||name.endsWith(".flv");
    			}
    		})) videoFiles.add("file:///" + (dir + "\\" + file).replace("\\", "/").replaceAll(" ", "%20"));
    		Collections.sort(videoFiles);
    		for(int kk=0;kk<videoFiles.size();kk++){
    			System.out.println(videoFiles.get(kk));
    		}
    
    		esegui();
    
    		// layout the scene.
    		layout.setStyle("-fx-background-color: black; -fx-font-size: 20; -fx-padding: 0; -fx-alignment: center;");
    		VBox vBox = new VBox();
    		vBox.setAlignment(Pos.CENTER);
    		vBox.getChildren().add(mediaView);
    		layout.getChildren().addAll(vBox);
    
    		return new Scene(layout);
    	}
    
    	public void esegui(){
    
    		nextFileIndex = (nextFileIndex + 1) % videoFiles.size();
                    playerNew = null;
    		System.gc();
    		playerNew = new MediaPlayer(new Media(videoFiles.get(nextFileIndex).toString()));
    		mediaView.setMediaPlayer(playerNew);
    		playerNew.play();
    		playerNew.setOnEndOfMedia(finale);
    
    
    	}
    	
    
    }
    It looks cleaner and seems to work well.
    Should I test it better.
    However, you have some advice to improve it?
    Thanks

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    You can skip this call:
    Java FX Code:
    System.gc();
    as it will not be achieving anything terribly useful.

    But that code there looks better, and keeps the media player in the narrowest scope, so the garbage collector should be able to clear it up. The threads also have a clear exit point, which I wasn't too sure was the situation in the earlier code.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #15
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,016
    Rep Power
    6

    Default Re: JavaFx and memory consumption

    Except for that GC call the code looks good to me! Of course something like this reads a little weird:

    Java FX Code:
    + (dir + "\\" + file).replace("\\", "/")
    Make up your mind dude ;)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  16. #16
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    Thanks for your answer.

    Quote Originally Posted by Tolls View Post
    You can skip this call:
    Java FX Code:
    System.gc();
    as it will not be achieving anything terribly useful.

    But that code there looks better, and keeps the media player in the narrowest scope, so the garbage collector should be able to clear it up. The threads also have a clear exit point, which I wasn't too sure was the situation in the earlier code.
    I deleted System.gc


    Quote Originally Posted by gimbal2 View Post
    Except for that GC call the code looks good to me! Of course something like this reads a little weird:

    Java FX Code:
    + (dir + "\\" + file).replace("\\", "/")
    Make up your mind dude ;)
    It is necessary because MediaPlayer accepts as a separator for local files only "/" .

    in addiction i'm running the application on a pc with those components :

    Windows7 with JRE 7 u55
    MOTHERBOARD ASUS M5A97 EVO R2.0 skAM3+ (UEFI BIOS - Sata 6Gbs - USB3.0 - Firewire - e-SATA CPU AMD FX-6300 X4 6-CORE 3.5GHz/4.1GHz socket AM3+ RAM CORSAIR VENGEANCE PRO KIT 2X4GB DDRIII 1600 (8GB)
    VIDEO AMD RADEON R7 260X OC 2GB GDDR5 (1x Dual-Link DVI-D - 1x Dual-Link DVI-I - 1x HDMI 1.4a 3D - 1x DisplayPort 1.2) - AMD TrueAudio - DirectX 11.2

    And i noticed that memory consuption is over 1Gb (on my pc is about 300Mb . I have Windows 8.0 with JRE 7 u55 ).
    In addition, they continue to create 80 thread after one hour.
    I'm getting crazy.

  17. #17
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,016
    Rep Power
    6

    Default Re: JavaFx and memory consumption

    Quote Originally Posted by Kyuzo View Post
    It is necessary because MediaPlayer accepts as a separator for local files only "/" .
    Indeed, so try explaining to yourself why you insist on adding the wrong slash to the path only to a nano second later replace it with the correct one.

    Java FX Code:
    videoFiles.add("file:///" + (dir.replace("\\", "/") + "/" + file).replace(" ", "%20"));
    You say "memory consumption" - how did you measure that on the other system? Again with JVisualVM?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    Hmm.
    It depends what the earlier thread does on end of media. I would have expected it to simply exit...

    As for the memory, how are you checking it?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  19. #19
    Kyuzo is offline Member
    Join Date
    Apr 2014
    Posts
    11
    Rep Power
    0

    Default Re: JavaFx and memory consumption

    Quote Originally Posted by gimbal2 View Post
    Indeed, so try explaining to yourself why you insist on adding the wrong slash to the path only to a nano second later replace it with the correct one.

    Java FX Code:
    videoFiles.add("file:///" + (dir.replace("\\", "/") + "/" + file).replace(" ", "%20"));


    You say "memory consumption" - how did you measure that on the other system? Again with JVisualVM?

    Ehmmm..yes..i changed it with

    Java FX Code:
    videoFiles.add("file:///" + (dir + "/" + file).replace("\\", "/"));

    replace instruction is necessary because there is :


    Java FX Code:
    final File dir = new File(System.getProperty("user.dir")+"//video");
    		if (!dir.exists() || !dir.isDirectory()) {
    			JOptionPane.showMessageDialog(null,"Cannot find video source directory: " + dir);	
    			System.exit(0);
    			return null;
    		}
    I'm in other system with TeamViewer.

    Quote Originally Posted by Tolls View Post
    Hmm.
    It depends what the earlier thread does on end of media. I would have expected it to simply exit...

    As for the memory, how are you checking it?
    Yes with VisualVm and Task Manager.
    To make you understand I send 4 screen.
    Attached Files Attached Files
    Last edited by Kyuzo; 05-12-2014 at 06:31 PM.

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default Re: JavaFx and memory consumption

    OK.
    So giving it a bigger screen increases the memory usage. No surprise there (IMO).

    The thread increase may be related to that.
    How long are the videos, on average?

    Also, what time did the videos start playing?
    17:00 or earlier? Just trying to see if the thread increase is something that occurs straight away, or something that takes time to build up.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Page 1 of 2 12 LastLast

Similar Threads

  1. How to reduce memory consumption in Java Desktop?
    By fanjavaid in forum Advanced Java
    Replies: 16
    Last Post: 07-19-2013, 04:59 AM
  2. JavaFX Book | Learn JavaFX More In Depth
    By SnakeDoc in forum JavaFX
    Replies: 0
    Last Post: 05-17-2013, 11:10 PM
  3. how to record maximum heap memory consumption
    By pvh35 in forum Advanced Java
    Replies: 2
    Last Post: 01-17-2011, 05:23 PM
  4. JavaFX Script and JavaFX Mobile
    By levent in forum Java Software
    Replies: 1
    Last Post: 01-27-2010, 04:48 PM
  5. Consumption of memory
    By Daniel in forum Advanced Java
    Replies: 1
    Last Post: 07-06-2007, 09:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •