How to free the memory after closing JavaFX Stage?

I am creating a JavaFx application which contain a button. When I click on that button, it opens a new stage containing a table with thousands of data. It's working fine. But the problem is, when I close the Stage of that table, memory is not getting free by the application i.e. everytime when I open the new stage for table then memory is get increased. Is there any issue with JavaFX? or I have to do something else?
I have tried to set everything null at the time of closing of that stage but still memory is not getting free.
My button click code is :
btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                Stage stage = new Stage();
                Table1Controller controller = (Table1Controller) Utility.replaceScene("/tablesample/Table1.fxml", stage);
                controller.init(stage);
                stage.setTitle("Sample");
                stage.setWidth(583.0);
                stage.setHeight(485.0);
                stage.initModality(Modality.APPLICATION_MODAL);
                InputStream in = TableSample.class.getResourceAsStream("icon_small.png");
                try {
                    stage.getIcons().add(new Image(in));
                } finally {
                    try {
                        in.close();
                    } catch (IOException ex) {
                stage.show();
Utility.replacescene method : It loads the scene from given fxml and set to stage. At final It return controller object for that scene.
public static Initializable replaceScene(String fXml, Stage mystage) {
        InputStream in = null;
        try {
            FXMLLoader loader = new FXMLLoader();
            in = Utility.class.getResourceAsStream(fXml);
            loader.setLocation(Utility.class.getResource(fXml));
            loader.setBuilderFactory(new JavaFXBuilderFactory());
            AnchorPane page;
            try {
                page = (AnchorPane) loader.load(in);
            } finally {
                in.close();
            Scene scene = new Scene(page);
            mystage.setScene(scene);
            return loader.getController();
        } catch (Exception ex) {
            return null;
    }Thanks

Is there any issue with JavaFX? or I have to do something else?It's likely an issue with your application code (though it could be a bug in the JavaFX platform too).
Either way debugging most memory issues in JavaFX (except for ones the graphics card texture related) is the same as debugging them in Java - so just use standard Java profiling tools to try to track down any memory leaks you have.
Such work is as much an art as a science and takes some experience to get right, so grab your detective cap, download and use the tools linked and try and track it down:
http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java
http://resources.ej-technologies.com/jprofiler/help/doc/indexRedirect.html?http&&&resources.ej-technologies.com/jprofiler/help/doc/helptopics/memory/memoryLeak.html
http://www.ej-technologies.com/products/jprofiler/overview.html (recommended tool).
http://visualvm.java.net/
http://netbeans.org/kb/articles/nb-profiler-uncoveringleaks_pt1.html
http://www.ibm.com/developerworks/library/j-leaks/ (this link is really old and somewhat outdated but explains some of the underlying concepts better than some newer articles I found).

Similar Messages

  • How can restore the memory after deleting parallels?

    I recently deleted my paralles program and wonder if the memory that it had been taking up has now been restored to my computer or if it is still partisioned off. I ask this because when I installed paralles, my mac asked me how much memory I wanted to give to paralles.
    Thanks for your help!

    Some ways to get space
    You can first remove seldom used apps. If you decide later you want them back you can always download them again. You can also download the Dropbox app and off load some of your little used pics and files to open up space. The app is free and you get 2 gb of free storage and if you get friends to install Dropbox they will give you 500 extra mb for each friend who installs it. Many apps will let you save direct to Dropbox.

  • How to clean the memory after calling BitmapData.draw() ?

    If you add the embedded image on the Stage 800x600 flash player will spend 17Mb RAM / 14Mb Virtual
    But if you create 1200 sprites (in every 100 circles), call draw (), remove the sprites and force to call Garbage Collector, flash player will spend much more - 36Mb RAM / 33Mb Virtual
    var container:Sprite = new Sprite();
    // adding 1200 sprites
    var shiftX:Number = 10;
    var shiftY:Number = 10;
    for (var i:int = 0; i < 1200; i++) {
         var circle:Sprite = new Sprite();
         // drawing 100 circles
         for (var j:int = 0; j < 100; j++) {
              circle.graphics.beginFill(0xFFFFFF/j*i);
              circle.graphics.drawCircle(0, 0, 10-j*.1);                        
         circle.x = shiftX;
         circle.y = shiftY;
         shiftX += 20;
         if ( shiftX >= stage.stageWidth ) {
              shiftX = 10;
              shiftY += 20;
         container.addChild(circle);
    // draw() and adding bitmap
    var bmd:BitmapData = new BitmapData(800, 600, true, 0x00FFFFFF);
    bmd.draw(container);
    var bmp:Bitmap = new Bitmap(bmd, "auto", true);
    addChild(bmp);
    // removing sprites
    while (container.numChildren) container.removeChild(container.getChildAt(0));
    // Force Garbage Collector 1
    System.gc();
    System.gc();
    // Force Garbage Collector 2
    try {
         new LocalConnection().connect('foo');
         new LocalConnection().connect('foo');
    } catch (e:Error) {}
    What happens to memory?

    Is there any issue with JavaFX? or I have to do something else?It's likely an issue with your application code (though it could be a bug in the JavaFX platform too).
    Either way debugging most memory issues in JavaFX (except for ones the graphics card texture related) is the same as debugging them in Java - so just use standard Java profiling tools to try to track down any memory leaks you have.
    Such work is as much an art as a science and takes some experience to get right, so grab your detective cap, download and use the tools linked and try and track it down:
    http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java
    http://resources.ej-technologies.com/jprofiler/help/doc/indexRedirect.html?http&&&resources.ej-technologies.com/jprofiler/help/doc/helptopics/memory/memoryLeak.html
    http://www.ej-technologies.com/products/jprofiler/overview.html (recommended tool).
    http://visualvm.java.net/
    http://netbeans.org/kb/articles/nb-profiler-uncoveringleaks_pt1.html
    http://www.ibm.com/developerworks/library/j-leaks/ (this link is really old and somewhat outdated but explains some of the underlying concepts better than some newer articles I found).

  • Free the memory of a String

    I am now creating a string object. I need to free the memory after using it,
    I dereference it now like this:
    String john = new String("John sucks");
    john = null;
    which doesn't free the memory the string object taken. Anybody have any suggestions of how to do it by using Garbage collection ? My friend told me that
    a String object can be never removed from the memory, is it true or not?
    Thank you very much

    I am now creating a string object. I need to free the
    memory after using it,
    I dereference it now like this:
    String john = new String("John sucks");
    john = null;
    which doesn't free the memory the string object taken.No it doesn't.
    Anybody have any suggestions of how to do it by using
    Garbage collection ? Forget about it.
    My friend told me that
    a String object can be never removed from the memory,
    is it true or not?Did your friend not also tell you to not worry about it?
    You have two strings.
    1. The internal string represented by "John sucks"
    2. A new string created by new String()
    The first will not be cleaned (at least not without involved class loaders.)
    The second will be cleaned when the garbage collector cleans it. Which it doesn't have to do until it feels like it.

  • How to free up memory in MacBook Pro?

    How to free up memory in MacBook Pro? (How to avoid getting the revolving rainbow?)

    I compressed some programs and data. I now have 4.56 GB free.
    SMART UTILITY http://www.volitans-software.com/smart_utility.php
    CAPACITY 80.0 GB
    SMART STATUS: YELLOW and "FAILING"
    "Removed 29 bad sectors
    Total errors 1708
    Reallocated 308 bad sectors"
    Do I need to buy Smart Utility?
    Had 5 simultaneous errors at READ DMA EXT. (I don't know what that means). I don't see all the windows that the web site shows. I guess that is for purchased downloads.
    I'd like to reinstate MobileMe's Backup function. Apple says it will work until June so that I could back that up until I get the backup hard drive. I was in the store last week; iCloud will not work on my computer.
    Thanks, DOTro

  • How to free allocated memory

    As we all know in java the memory allocated for an object is freed automatically when there is no reference for that object exist. and there is no operator in java to free the memory explicitly like delete() in c++.
    But i want to free the memory allocated for the object in java for my project.
    but i dont know how to do this.
    Any idea abt this?

    ghanoz2480 wrote:
    emmmh,,,see the following documentation:
    [http://java.sun.com/javase/6/docs/api/java/lang/System.html#gc()|http://java.sun.com/javase/6/docs/api/java/lang/System.html#gc()]
    Edited by: ghanoz2480 on 10 Mei 09 6:58From your link:
    "Calling the gc method *_suggests_* that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects. "
    That does not guarantee that the gc will be run.
    As the OP has already said, and as Jos has already highlighted - what the OP wants to do cannot be done in java.

  • How many free disk space after install OS X lion (10.7) ?

    Hi,
    I would like to know that how many free disk space after install OS X lion (10.7) on MBA i5.
    Many Thanks,
    Eric

    I want to buy MBA i5, I would like to free disk space of MBA 13" i5, Could anyone tell it to me? Thanks
    As you're buing a new MacBook Air, it will come pre-installed with Lion.  The actual installation will be somewhat larger than a "clean" Lion install as it will come with iLife preinstalled.  Obviously, with an Air's limited storage space, you want to be sure that you have enough room for any applications and data that you'll want to keep on the SSD as well.  It is fairly easy to upgrade the SSD on an Air:
    http://eshop.macsales.com/shop/SSD/OWC/Aura_Pro_Express
    The amount of RAM you have installed is probably more important.  Fortunately, the newest 13" MacBook Airs all come with 4GB standard now.

  • Refresh the table after closing the Popup iView

    Hi all,
    I have list of survey in my table. In that table i have toolbar button(DELETE) for deleting the survey. While deleting the survey it asks the confirmation. If we click Ok it delete the selected survey and close the popup also. what I want is I should refresh the table after closing the Popup.How can i achieve this?
    Help me in this regard.
    Thanks & Regards,
    Hemalatha J

    Hi Hema,
    Check this link.
    Visual Composer - You can do anything....
    In this blog, they are used 'Refresh' Button and a Hidden 'Plain text' message to solve this problem. If you are satisfy with this you can take this solution.
    Or you can try to trigger the 'Submit' action of 'Input form' once again from the 'Popup window' when the 'Delete' button is clicked.
    Hope it helps...
    Regards
    Basheer
    Edited by: Basheer on Dec 23, 2008 8:03 PM

  • How to overcome the Memory leakage issue in crystal report 2008 SP2 setup.

    I have developed the small windows based application tool with help of  Visual studio 2008 for identify the memory consumption of crystal report object. It helps to load the crystal report objects in the memory and then released the object from the memory. The tool simply does the u201CLoading and Unloadingu201D the objects in the memory.
    The tool will be started once u201CTest_MemoryConsumption.Exeu201D executed. The u201CTest_MemoryConsumption.Exeu201D consumes u201C9768 KBu201D memory before load the crystal report object in memory. It means, 9768 KB is normal memory consumption for run the tool.
    Crystal report object initiated by the tool and object help to load the report in memory once the tool initiated the crystal report object. Now u201CTest_MemoryConsumption.Exeu201D consumes u201C34980 KBu201D memory during the crystal report object creation and report load process. The actual memory consumption of crystal report object is 34980u20139768=u201C25212u201DKBu201D. 
    The memory consumption u201C34980 KBu201D will be continued till the end of the process. The memory consumption will be reduced to u201C34652 KBu201D from u201C34980 KBu201D once report load process completed. It means, u201C328 KBu201D memory only released from the memory consumption. Tool enables the Release command for the crystal report object. But crystal report object does not respond to the command and will not release his memory consumption.
    The memory consumption u201C34652 KBu201D will be stayed in the memory once job ends.  If i again initiate the crystal report object then it crystal report object start to consume the memory from 34652 KB.
    Database objects and crystal report objects are properly used in the tool. The object release commands properly  communicated to crystal report setup. But the u201CCrystal report service pack 2u201D setup unable to respond the commands which has enabled from .Net Tool.  Crystal report objects are properly initiated and disposed in the tool. But the crystal report unable to release from the server.
    The memory consumption will be reduced once the server restarted or kill the application.
    Crystal report 2008 and crystal report 2008 SP2 setup available in the server.
    Microsoft .Net Framework 2.0 SP2, Microsoft .Net Framework 3.0 SP2 and Microsoft .Net Framework 3.5 SP1 are available in the server,
    Could you please suggesst how to avoid the memory consumption keep increasing and  how to release the memory consumption  once the crystal object disposed???

    Hi Don..
    My case is different one. I hope, the problem with Run time Installation setup file (Crystal report 2008 Serivce Pack2 installer) which we installed in the server.
    Let me explain with Live scenario which our client faced in crystal report 2008 Service pack2 Installer.
    Our client is using a application to help to print their reports. The application is developed with Windows service.
    Windows service keep on running in the server. Windows service executes the client 's crystal reports( Labels Report, Stock  report) which designed for clients need and the reports will be printed from printer. 
    10 Same type report (Label Report) will be printed in 1 minute. Reports are not printing during non business hours. But the windows service keep on running.  Memory cosumption of application will be 160 MB in business hours.
    For Example, On Monday the application memory consumption starts with 160 MB. The Memory consumption will be reached 165 MB  in peak business hours. Then the memory will be ended in163 MB in the End of Monday. It means, The memory consumption will be in 163 MB during the non business hours. Reports will not be printed in non business hours.
    On Tuesday, the application memory consumption starts with 163 MB and it will be reached 168 MB during the peak hours. The Memory consumption will be ended in 165 MB in the end of Tuesday.  The same process contiues till friday. End of friday, the memory consumption of the application will be ended with 170 MB.
    Application Memory Consumption slowly increasing in the server. In 5 days, Memory consumption reached Threshold value (170 MB) of the server. Application gets hanged up once the memory consumption reached 170 MB. We got the error messages as "Attempted to read write protected memory " / "Not Enough memory for process".  If we restart server / If we restart the service then memory consumption of application get reduced to 160 MB.
    From the above scenario, We came know that the either the problem with Application object or the problem crystal report object. In the application, We have checked dispose methods of application objects completly. I am sure that  application objects are properly disposed in the application. I hope the problem not with application objects. The problem with Crystal report objects.
    Application properly communicates the dispose methods to crystal report objects. Crystal report objects are not released from
    the memory.
    Crystal report 2008 Serive Pack 2 setup installed in the server. 
    As you said, If Crystal report runtime is not released from memory then memory consumption keep increase???  In service oriented architecture application, how to unload the crystal report runtime??
    Do you any fix for this kind of issue??
    Willl Crystal report 2008 service pack 3 help on this issue??

  • How to enable the memory remapping in the bios?

    How to enable the memory remapping in the bios?
    my laptop: m100 psmaaq-00s003

    Without removing a specific Windows Update KB Patch, and two registry keys, you CANNOT uninstall the Flash Player ActiveX Plug-in for IE in Win 8.
    Microsoft released a new update for Flash Player in IE just the other day.
    Have you run Windows Update recently?

  • How to enable the screen after triggering the error message

    Hi All,
    we have a tcode IW31, in that one field(WBS element -PROID) is not mandatory. so we have written the following code to make it mandatory in a user exit EXIT_SAPLCOIH_010.It's triggering the error message, but it is going into disable mode. Please sugget me how to enable the screen after getting the error message triggering.
    if not caufvd_imp-proid is initial.
      select single * from t350 into wa_t350
              where  auart    = caufvd_imp-auart
                and  imord    = 'X'.
      if sy-subrc is initial.
        pspel = caufvd_imp-proid.
      else.
        call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
             exporting
                  input  = caufvd_imp-proid
             importing
                  output = l_posid.
        concatenate text-t10 l_posid text-t11
                    into l_textline1 separated by space.
        message i208(00) with l_textline1.
      endif.
    else.
      message e208(00) with 'Please maintain WBS element in Location Tab'.
    endif.
    Thanks

    Hi,
    Instead of error message use status message like
    message s208(00) with 'Please maintain WBS element in Location Tab'.
    Leave to screen sy-synnr.
    This will allow to move to the screen and have in enable mode.
    WIth Regards,
    Dwaraka.S
    Edited by: Dwarakanath Sankarayogi on Feb 13, 2009 7:46 AM

  • Anyone knows how to get the photos after IMG_9999 from iphone? :-(ps:... i got them all in my camera roll but when i connected to the computer there's nothing after IMG_9999..

    anyone knows how to get the photos after IMG_9999 from iphone? :-(ps:... i got them all in my camera roll but when i connected to the computer there's nothing after IMG_9999.. many thanks :-)

    They show in the camera roll, just not your computer?
    Have you checked every folder that is in the DCIM folder?

  • How to define the memory leak in stability test

    Hi
    Usually, we run our system with 70% CPU load for 72 hours for stability test (on solaris 10), because some plugin of our system is using mtmalloc, and we use prstat to monitor the memory of each plugin. But because of the complex memory usage of our application, we don't know when the application will use the Max memory, and because of the "mtmalloc", the memory showed by "prstat" will not released but continually increased.
    So fro the test point of view, there is the risk of memory leak, but actually, there may be no memory leak, so my question is how to define the memory leak in such condition.

    kevin wrote:
    Thank you for the input and all the info.
    isn't java heap the same as memory allocated to the java process in my weblogic
    starup script ?The heap is sized by the -Xmx and -Xms parameters you pass on the java
    command-line. The permanent generation is separate.
    >
    let me also download jprobe and try to run it and see what it gives me.
    I'd start by running with -verbose:gc. I'd want to know whether you're
    running out of heap or permgen space.
    -- Rob
    kevin
    Rob Woollen <[email protected]> wrote:
    Unfortunately memory leaks are not fun to track down even with tools.
    I'd first suggest determining whether you're running out of space in
    the
    permanent area (where classes are loaded), or you've exhausted the java
    help space.
    I'd start by adding -verbose:gc. Look at the gc messages right before
    you hit the OutOfMemoryError. If there's plenty of space left, I'd
    suspect you're running out of perm space. Search these newsgroups and
    the web for MaxPermSize, and you should see plenty of info.
    If you're running out of java heap, tools like jprobe and OptimizeIt
    are
    helpful. If you can tell me a little more about your application and
    how you're testing it, I can offer some more tips.
    -- Rob
    kevin wrote:
    Iam new to JAVA and weblogic. I have an application that runs out ofmemory time
    and again.
    please let me know how to pin point this problem and moreover, howto interpret
    or understand that there is a problem. I have downloaded JPROFILE tool,but it
    is very confusing to understand what is goin on in this tool.
    If somebody can let me know how to interpret and understand the memoryleak, that
    will be great !!!
    thank you.

  • How to suspend the installation after downloading packages via ota for lollipop 5.0.1. on my Note 4. always asks me to install it on notification bar. thank you :)

    How to suspend the installation after downloading packages via ota for lollipop 5.0.1. on my Note 4. always asks me to install it on notification bar. thank you

    If you factory reset, it wont make the update go away, but you should back up and reset before you install the update.

  • How to get the memory address of an array (pointer in C)?

    I am writing an application that exchanges data with a PXI device via DMA.  Basically I will provide it a memory address and a direction, and it transfers the data.  I would like to give it the memory location of an array in LabVIEW, but I do not know how to get the memory location without doing a DLL call to C code that returns the pointer.  Is there an easy way to do this in LabVIEW?  Any help is much appreciated.

    A similar question was asked recently regarding strings. You cannot pass pointers in LabVIEW as you do in C. You can pass an array to a DLL, but that means you would need to write a wrapper DLL. Be sure to read the section in the LabVIEW Help on calling code from text-based languages and also take a look at the "Call DLL" example that ships with LabVIEW  - it contains many examples of how to deal with various datatypes.

Maybe you are looking for

  • How do i sync my outlook account to mail,calendar on macbook pro

    hi , i use a macbook pro . & i want to sync my outlook account to mail , contacts and calendar , and recieve notifications . but i cant assign my account to it . please suggest a solution for me.

  • I DOWNLOADED A NEW ITUNES VERSION AND MY PODCASTS DISAPPEARED FROM THE LIBRARY

    When I downloaded the second to last version of iTunes to a Windows PC, my podcasts disappeared from my iTunes library and seem to be elsewhere in my computer. Yet iTunes still says I have 80 podcasts. And podcasts still download to somewhere in my c

  • Add new key figs or characteristics and "Repair full request"

    Hi Gurus, here are my questions 1.If I add new key figs or characteristics(which are not Key fields) to ODS and Cube containing tons of data, Will the transport for structure changes fail due to presence of data? 2.The extractor to the ODS which intu

  • Exceeded configured maximum number of allowed output

    I keep getting 'Exceeded configured maximum number of allowed output prompts, sections, rows, or columns.' Error Codes: IRVLJWTA Location: saw.views.dashboard, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.ha

  • Executing matlab in java

    HI, I'm using a java class called JMatlink to connect my java program to Matlab (a mathematic tool). To do this we must write : JMatLink engine = new JMatLink(); engine.engOpen(); I tested a sample like this and it work very well. But when i do the s