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
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!
The same problem happens in that case.
The problem is if you have 3 Scenes, you load the first session and let's say it uses 100 MB of memory, now you need the second one and it uses 30 MB, then you load the third one, another 50 MB, in that moment you are using 180 MB of memory,
it's not possible to free memory even putting the scenes to null and calling the garbage collector.