wood burning stoves 2.0*
The moose likes JavaFX and the fly likes JavaFX never free memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JavaFX
Bookmark "JavaFX never free memory" Watch "JavaFX never free memory" New topic
Author

JavaFX never free memory

j horto
Greenhorn

Joined: May 16, 2011
Posts: 1
Hello everyone,

I hope someone can help me, I'm creating a JavaFX Desktop Application, it's the common desktop application with several windows where you can browse selecting different MenuItems.

The problem comes when I've realized JavaFX never free memory, if I check my windows monitor, the memory is always increasing, even if I do nothing, if I leave the application running, where I know that nothing (developed by me) is running, the memory keeps increasing.
This is not a big problem because, there is a point where it stops.

My main concern is switching between windows, let's say I have two screens, one with the User Management and the other one with Group Management, if I want to load the User Management screen, I empty the main panel, create an instance of User Management and copy all the content into the panel (which I previously deleted all the content).
Now if I have to load the Group Management, I removed all the content of the main panel, create an instance of Group Management and copy all the content of the Group Management into the panel.

The problem with JavaFX is: never free memory, every time I create a new object, the object is there, even if I delete the panel (the object is not referenced, so Garbage Collector should free that memory, but it doesn't).

One extreme thing I did (I'm a bit desperated with this issue) is for every panel, launch a "standalone" window, so when I want to free memory, I just need to close the window, that means the elements of that window won't be referenced by any element, so if I close the window, the memory should be freed. To be clearer let's see this example:
I have a main window, with two options: one for User Management and the other for Group Management.
To open one or other I use

or



when executed that a new window is open, a window that I can close and my program keeps executing, the problem is when the window of the User Management or the Group Management is closed the memory is not freed.
Imagine one of that window has 200 checkboxes, images, etc... and it uses like 60-80 MB, I'd like to free that memory, because that window can be opened several times and at certain point, the application becomes extremely slow and needs to be restarted, which is not acceptable.

Any help, please let me know.
Thanks for reading all of this!
Antonio Jimenez
Greenhorn

Joined: Dec 25, 2011
Posts: 4
Hello j-horto!

Actually, I have exactly the same problem and I'm searching for a solution to this issue. Have you found any solution that you can share to me?

I will be really grateful with you!

Bye!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3070
    
  33

I think, looking at the sample you have posted, you are still using JavaFX 1.2 or 1.3. JavaFX versions prior to 2.0 are no longer supported. So you have to move your applications to JavaF 2.0 API. And in JavaFX 2.0, you create javafx applications using the JavaFX API and not JavaFX script.
The Runtime or the JavaFX SDK needs to be installed separately and as of now are not bundled with the JDK.

So you can start learning javafx 2.0 here.


Mohamed Sanaulla | My Blog
Antonio Jimenez
Greenhorn

Joined: Dec 25, 2011
Posts: 4
Mohamed Sanaulla wrote:I think, looking at the sample you have posted, you are still using JavaFX 1.2 or 1.3. JavaFX versions prior to 2.0 are no longer supported. So you have to move your applications to JavaF 2.0 API. And in JavaFX 2.0, you create javafx applications using the JavaFX API and not JavaFX script.
The Runtime or the JavaFX SDK needs to be installed separately and as of now are not bundled with the JDK.

So you can start learning javafx 2.0 here.


Hi Mohamed,

No, I'm using JavaFX 2.0. I think it is a problem JavaFX has since 1.2 or 1.3. I really don't know how solve it, there's no a good solution in any other forum.

If you can help me, I will be very grateful!

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4542
    
    5

Antonio Jimenez wrote:
Mohamed Sanaulla wrote:I think, looking at the sample you have posted, you are still using JavaFX 1.2 or 1.3.


Hi Mohamed,

No, I'm using JavaFX 2.0.


Then why do you mislead the forum by posting JavaFX Script? In future, please PostRealCode.

If you don't run into OutOfMemoryError, there's nothing to be concerned about. The behavior you describe is normal for any Java application and not specific to JavaFX 2.0 (or any earlier version).

Garbage Collector should free that memory, but it doesn't ... when I want to free memory, I just need to close the window, that means the elements of that window won't be referenced by any element, so if I close the window, the memory should be freed.

The GC frees up memory and makes it available to the JVM. That doesn't mean that the memory is released to the OS.

If you're short on RAM, try reducing the memory available to the JVM by running with the -Xmx flag.


luck, db
There are no new questions, but there may be new answers.
Antonio Jimenez
Greenhorn

Joined: Dec 25, 2011
Posts: 4
Darryl Burke wrote:
Antonio Jimenez wrote:
Mohamed Sanaulla wrote:I think, looking at the sample you have posted, you are still using JavaFX 1.2 or 1.3.


Hi Mohamed,

No, I'm using JavaFX 2.0.


Then why do you mislead the forum by posting JavaFX Script? In future, please PostRealCode.

If you don't run into OutOfMemoryError, there's nothing to be concerned about. The behavior you describe is normal for any Java application and not specific to JavaFX 2.0 (or any earlier version).

Garbage Collector should free that memory, but it doesn't ... when I want to free memory, I just need to close the window, that means the elements of that window won't be referenced by any element, so if I close the window, the memory should be freed.

The GC frees up memory and makes it available to the JVM. That doesn't mean that the memory is released to the OS.

If you're short on RAM, try reducing the memory available to the JVM by running with the -Xmx flag.


Hi, Darryl,

First I want to tell you is that the first post is not mine! So I've never post any JavaFX Script... I said that I have the same problem that J-horto has. I didn't try to mislead anyone in this forum.

Second, I know that is a JavaFX problem because JavaFX keeps some references to Objects that I actually don't use!!!
Those Objects are no more on the Screen, and If you have to load many pictures and you don't need them any more later, you want that the GC does its work...But it doesn't happen!

Bye
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3070
    
  33

Antonio Jimenez wrote:
Hi, Darryl,

First I want to tell you is that the first post is not mine! So I've never post any JavaFX Script... I said that I have the same problem that J-horto has. I didn't try to mislead anyone in this forum.

There was some confusion as my reply was to the OP but you replied to my post so that setup a flow. Nevermind.

Antonio Jimenez wrote:
Second, I know that is a JavaFX problem because JavaFX keeps some references to Objects that I actually don't use!!!
Those Objects are no more on the Screen, and If you have to load many pictures and you don't need them any more later, you want that the GC does its work...But it doesn't happen!

Bye

I havent myself tried something in those lines. But if you find such issues, I think you can file a bug for that.
Antonio Jimenez
Greenhorn

Joined: Dec 25, 2011
Posts: 4
Mohamed Sanaulla wrote:
Antonio Jimenez wrote:
Hi, Darryl,

First I want to tell you is that the first post is not mine! So I've never post any JavaFX Script... I said that I have the same problem that J-horto has. I didn't try to mislead anyone in this forum.

There was some confusion as my reply was to the OP but you replied to my post so that setup a flow. Nevermind.

Antonio Jimenez wrote:
Second, I know that is a JavaFX problem because JavaFX keeps some references to Objects that I actually don't use!!!
Those Objects are no more on the Screen, and If you have to load many pictures and you don't need them any more later, you want that the GC does its work...But it doesn't happen!

Bye

I havent myself tried something in those lines. But if you find such issues, I think you can file a bug for that.


Yep, sorry Mohamed!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4542
    
    5

Mohamed Sanaulla wrote:
Antonio Jimenez wrote:
Hi, Darryl,

First I want to tell you is that the first post is not mine! So I've never post any JavaFX Script... I said that I have the same problem that J-horto has. I didn't try to mislead anyone in this forum.

There was some confusion as my reply was to the OP but you replied to my post so that setup a flow. Nevermind.


Yup. My apologies.
Guido Granobles
Greenhorn

Joined: Sep 11, 2010
Posts: 22
Hi Antonio Jimenez did you find any solution to this problem ? I'm really desperate with this, even I'm using JavaFX 2.1


http://guido-granobles.blogspot.com
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1083
    
  10

Hi Guido,
This is an old topic and has discussions related to both the older script-based version and the new one. Hence, I would suggest you to create a fresh topic with more details about the code, environment, version etc. Also, read this: TellTheDetails


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaFX never free memory