Clear Memory Used by Vectors When You Close an Application:

Which is the best way for liberate the memory used by the Vectors when you close the application that contain them?
In particular:
I use vec.clear(); when I close the Frame that contains the application, but I'm not sure if this is the best way.
Could S.O. tell me wether I'm wrong or not?
Thanks in advance!

A few things that may apply:
Until you have references to a variable, then the garbage collector will not free the memory allocated for that variable. For example:
Vector my_vector = new Vector();
Vector vector_2 = my_vector;
Until both my_vector and vector_2 are valid references, then the memory will not be freed.
You can get rid of a reference to a variable setting it to null. In our example:
my_vector = null;
vector_2 = null;
Then, the next time garbage collection runs, it will free the memory allocated for my_vector
If you cannot wait for the next time that garbage collection runs, you can explicitely force garbage collection.
System.gc();
Hope this helps.

Similar Messages

  • Executables throw a widows error when you close the application

    I have this problem on several of my labview executables.  I can open and runt eh program with no errors.  But when I close the program by any method, I get a pop up error in windows. Stating:
    "Application Name" has encountered a problem and needs to close.  We are sorry for the inconvenience. 
    I get the option to send the info to Microsoft.  Another error pops up Stating the following:
    WinsockAsyncSelectWindow:  Application name.exe - application error
    The instruction at "0x7c90e470" referenced memory at "0x03182a2c". The memory could not be "read".  Click on CANCEL to debug the program.
    This is really annoying... Anyone know why this error is poping up?

    Hi Jason,
    Could you please provide us with some more information regarding your executable?
    What version of LV are you using?
    How are you stopping the executable (stop button?  abort button?)  You should always use a stop button, not the abort button (the stop sign looking glyph on the toolbar) to ensure that all of your references have been properly closed. 
    Do you see this performance when running the executable on the development machine?
    Do you get the warning every time, or only some of the time?
    What all are you doing in the executable?  I'd be curious to know if it was something particular to your code or the environment.  One way to test this is to build a "dummy" executable--just one that does something as simple as count iterations, and see if you get the message or not.  
    Please provide a little more information and we'll do our best to help. 
    Cheers, 
    Marti C
    Applications Engineer
    National Instruments
    NI Medical

  • Is it possible to save a Photoshop project with multiple tabs (inducing images) for later use. Now, when I close Photoshop, it ask to save each tab separately and they are not staying in the project for later usage. Thanks in advance for you help.

    Is it possible to save a Photoshop project with multiple tabs (inducing images) for later use. Now, when I close Photoshop, it ask to save each tab separately and they are not staying in the project for later usage. Thanks in advance for you help.

    You should ask in Photoshop General Discussion
    The Cloud forum is not about using individual programs
    The Cloud forum is about the Cloud as a delivery & install process
    If you will start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • App Tabs do not load on restart. "All of the App Tabs you have set when you close Firefox will open as App Tabs when you start Firefox again."

    Use FF3 and taking a look at FF4. I set up some App Tabs. Close FF4. Open FF4. No App Tabs.
    Any Help?

    Are you clearing your recent history when you close Firefox?
    Firefox stores App Tabs and tab group details in the same file that stores details of browsing sessions. Make sure that you have not set Firefox to delete browsing history. For details of the setting to check see https://support.mozilla.com/kb/Clear+Recent+History

  • When I open iWeb it does not "Highlight" the New site or new page options. It ahs had this issue for over a year! I have tried uninstalling and re-installing it. What do I do? It opens the tutorial video, then when you close it, nothing else is clickable.

    When I open iWeb it does not "Highlight" the New site or new page options. It has had this issue for over a year! I have tried uninstalling and re-installing it. What do I do? It opens the tutorial video, then when you close it, nothing else is clickable.

    Open iPhoto, select a couple of photos and use the Share ➙ iWeb ➙ Photo page menu option.  That has jump started iWeb for others.  I could take a couple of tries.
    If that doesn't work try the following:
    1 - delete the iWeb preference file, com.apple.iiWeb.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete iWeb's cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iWeb folder. 
    Click to view full size
    3 - launch iWeb and try again.
    OT

  • I copied this from your 5.0 download information: "All of the App Tabs you have set when you close Firefox will open as App Tabs when you start Firefox again." When I opened my computer today all my apptabs from yesterday had disappeared. Why?

    Your download page for 5.0 stated: All of the App Tabs you have set when you close Firefox will open as App Tabs when you start Firefox again.
    I liked the convenience of using App Tabs and was disappointed to find that the ones I had set up yesterday were gone today. Am I doing something wrong?

    Works fine for me, I can simulate your problem by improperly closing Firefox.
    The correct way would be to close the windows you don't want and then to exit Firefox through the File ("'''Alt+F'''") menu then use '''Exit''' or '''Qui'''t depending on your system.
    But '''I can simulate your problem''' by closing the good window with "X" in the upper right-corner first (the one with the app-tabs) and then close the other window by any means.
    You restart Firefox and open a window, since you closed without app-tabs there are none so you just see a window with your home page.
    Firefox has some things added to Firefox 4 and therefore in Firefox 5.
    # "'''Alt+S'''" (Hi'''s'''tory menu)
    # "'''Restore Previous Session'''" (that's the window without the app-tabs, but you have to this first)
    # "'''Restore Recently Closed Windows'''" -- can choose which window to reopen based on name and the mouse-over tells how many tabs. or you just use "'''Restore All Windows'''" without the guessing.
    ''I know you are on a Mac, and this affects Windows user more than anybody else, but it does affect other systems besides Windows, occasionally, perhaps more often now with the plugins container.''
    The following may not completely eliminate having to terminate Firefox through the Windows Control Panel but it will come very close.
    '''Plug-in and tasks started by Firefox may continue after attempting
    to close Firefox''' The "X" in the upper right-hand corner closes the
    Window (same as Ctrl+Shift+W) but even if it is the last Firefox window,
    it does not necessarily close Firefox .
    The only '''proper way to exit Firefox''' is to use '''Exit''' through the
    File menu, not the "X" in the upper right corner of last Firefox window.
    In the Firefox 4 and 5 that would be Alt+F then X
    * '''Firefox hangs''' | Troubleshooting | Firefox Support <br>http://support.mozilla.com/en-US/kb/Firefox%20hangs#w_hang-at-exit
    Use the '''Windows Task Manger''' to remove all running firefox.exe in the "'''Processes'''" tab of the Windows Task Manager, then restart Firefox.
    If Firefox will still not start, remove the parent.lock file from the profile which is created each time Firefox is started to prevent other Firefox tasks from running, see<br>
    http://kb.mozillazine.org/Profile_in_use#Remove_the_profile_lock_file
    '''Avoiding Problems with close/restart''' ''choose either extension''
    :Use to close and restart Firefox after enabling or disabling an extension, switching to a new theme, or modifying configuration files, then you don't have to worry about delay or have to look in the Task Manager to see if Firefox is closed yet.
    Both extensions use the same keyboard shortcut "'''Ctrl+Alt+R'''" or a file menu option.
    *"'''Restartless Restart'''" extension for Firefox 4.0+ only (2 KB download ) <br>https://addons.mozilla.org/firefox/addon/249342/
    *For older versions use "'''QuickRestart'''" extension (34 KB download) (<br>https://addons.mozilla.org/firefox/addon/3559/

  • Confirmation from Safari when you close a window on Mavericks

    Hi all,
    I was wondering if it was possible to have like a little warning from Safari when we quit a window on this application. For example: Are you sure you want to quit this window?". Firefox has this application when you close a window with several tabs.
    I looked in the preferences, but i haven't found it. I know this kind of warning was present on the elder versions of Safari, so why not now?
    Hope you can help,
    Tim
    I have a MacBook Pro, OS X Mavericks (10.9.2) and the Safari 7.0.2

    Actually, you're right. After a little investigation, it was the way I was using the gui that was making this happen. During debuging (using Netbeans) I would open the dialog window then click on netbeans to check the console for a couple System.out.println()'s I put in the code. Then on closing the Dialog window Netbeans would be the next window selected by the OS and would appear over the original JFrame. D'oh! Just sillyness on my part imagining problems for myself.
    I guess what I was looking for was that when I close the dialog window that the OS would focus to the parent JFrame instead of the previously viewed application.
    Thanks!

  • Flash quits when you close the window

    Why does Flash CS5 quit when you close the window you were working in? It has to restart every time you close and open a file.

    This doesn't seem to be a crashing issue. The program seems to be designed like Windows, wherein the application quits when you close the last open window. This is incredibly annoying and completely unacceptable.

  • Why my smart folders dissapear in mail when i close mail application in mountain lion?

    Why my smart folders dissapear in mail when i close mail application in mountain lion?
    Please help!

    My results jumped up from around 1000 to 10,000 when I did that.
    I think this may have to do with having x11 and xcode installed.
    In case anyone is interested, these are the folders I've had to exclude:
    User\Library\Developer
    System\Library\Frameworks
    opt in the root folder of the HD (this is x11. You may have to Finder's 'go to folder' option to get to it.)
    There was also Office stuff coming up which looks like it's from the system when you see it (the identities folder and the subfolder within the Office 2011 folder in Applications)
    The combination of this stuff seemed to create the impression of more files from the System and Library folders were coming up than actually were.
    In case anyone is still reading, the stuff *still* being thrown up that I'm aware of is
    Mountain Lion screensavers from the System and Library folders.
    PreferencePanes - System, PreferencePanes - User and PreferencePanes - Library folders, which each show up as individual results.
    But, as you say, bispymusic, perhaps Apple has deigned that those folders appear in results. Thanks a lot for your help! Have a good one.

  • How you close an application on ipad 4 after installing ios 7

    How you close an application on ipad 4 after installing ios 7

    Double click the Home button to show the screen with running and recently used apps. Each app icon will have a sample page above it. Flick up on the page (not the app icon) and the page will fly away and the app icon will disappear. This quits that app.

  • I have a problem with buying apps in itunes Store. When you purchase the application fails payment. Asked to update the map. I have 2 credit cards with a positive balance. In what could be the reason?

    I have a problem with buying apps in itunes Store.
    When you purchase the application fails payment.
    Asked to update the map.
    I have 2 credit cards with a positive balance.
    In what could be the reason?

    contact itunes support

  • MAC is turned off when you start the application.

    MAC выключается при запуске приложений.
    MAC is turned off when you start the application.
    P.S. it is desirable to give an answer on the Russian
    Interval Since Last Panic Report:  69711 sec
    Panics Since Last Report:          1
    Anonymous UUID:                    BF785864-5B2E-7638-B9E8-ED938B20D6F6
    Thu May 23 20:28:41 2013
    panic(cpu 2 caller 0xffffff80242b7e95): Kernel trap at 0x0000000000000000, type 14=page fault, registers:
    CR0: 0x0000000080010033, CR2: 0x0000000000000000, CR3: 0x00000000053ca068, CR4: 0x00000000001606e0
    RAX: 0xffffff8024813e10, RBX: 0x0000000000000001, RCX: 0xffffff80248e04f0, RDX: 0xffffff8024890100
    RSP: 0xffffff810cd7b978, RBP: 0xffffff810cd7b9a0, RSI: 0x0000000000000001, RDI: 0xffffff8045a66410
    R8:  0x000000000000000e, R9:  0xffffff8045a90908, R10: 0xffffffffffffffff, R11: 0x00000000ffffffff
    R12: 0xffffff803e98cc02, R13: 0x0000000000000000, R14: 0xffffff803e98cc10, R15: 0xffffff8045a66410
    RFL: 0x0000000000010202, RIP: 0x0000000000000000, CS:  0x0000000000000008, SS:  0x0000000000000010
    Fault CR2: 0x0000000000000000, Error code: 0x0000000000000010, Fault CPU: 0x2
    Backtrace (CPU 2), Frame : Return Address
    0xffffff810cd7b610 : 0xffffff802421d626
    0xffffff810cd7b680 : 0xffffff80242b7e95
    0xffffff810cd7b850 : 0xffffff80242cd4dd
    0xffffff810cd7b870 : 0x0
    0xffffff810cd7b9a0 : 0xffffff80242772b2
    0xffffff810cd7b9d0 : 0xffffff8024585aae
    0xffffff810cd7b9e0 : 0xffffff80242f0981
    0xffffff810cd7ba30 : 0xffffff80242f0021
    0xffffff810cd7ba70 : 0xffffff80242f10d6
    0xffffff810cd7baa0 : 0xffffff80242ed939
    0xffffff810cd7bac0 : 0xffffff8024515c0a
    0xffffff810cd7bb20 : 0xffffff802431112c
    0xffffff810cd7bb90 : 0xffffff80242fc5f1
    0xffffff810cd7bd90 : 0xffffff80242fc93d
    0xffffff810cd7bf50 : 0xffffff80245e063a
    0xffffff810cd7bfb0 : 0xffffff80242cdd23
    BSD process name corresponding to current thread: installd
    Mac OS version:
    12D78
    Kernel version:
    Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST... [Show more]

    A: MAC is turned off when you start the application.

    I took in the store returned MAC. Although when you start offering configure everything from scratch. The OSes can reinstall?
    Last night passed out on completion of the work.
    Interval Since Last Panic Report:  75071 sec
    Panics Since Last Report:          2
    Anonymous UUID:                    BF785864-5B2E-7638-B9E8-ED938B20D6F6
    Thu May 23 23:25:35 2013
    panic(cpu 2 caller 0xffffff80036b7e95): Kernel trap at 0xffffff80036102b1, type 14=page fault, registers:
    CR0: 0x0000000080010033, CR2: 0x0000000000040001, CR3: 0x0000000079b9d056, CR4: 0x00000000001606e0
    RAX: 0x0000000000040001, RBX: 0x000000000000002c, RCX: 0x7fffffffffffffff, RDX: 0xffffff80f546bd88
    RSP: 0xffffff80f546bd30, RBP: 0xffffff80f546bd70, RSI: 0x000000000000002c, RDI: 0xffffff80f546bdb0
    R8:  0x000000000000001f, R9:  0x00000000000003ff, R10: 0xffffffffffffffff, R11: 0x00000000ffffffff
    R12: 0xffffff802a9a6a20, R13: 0x0000000000000001, R14: 0x0000000000000070, R15: 0x0000000000040000
    RFL: 0x0000000000010216, RIP: 0xffffff80036102b1, CS:  0x0000000000000008, SS:  0x0000000000000010
    Fault CR2: 0x0000000000040001, Error code: 0x0000000000000000, Fault CPU: 0x2
    Backtrace (CPU 2), Frame : Return Address
    0xffffff80f546b9d0 : 0xffffff800361d626
    0xffffff80f546ba40 : 0xffffff80036b7e95
    0xffffff80f546bc10 : 0xffffff80036cd4dd
    0xffffff80f546bc30 : 0xffffff80036102b1
    0xffffff80f546bd70 : 0xffffff8003620dc4
    0xffffff80f546bda0 : 0xffffff800364f0c1
    0xffffff80f546bde0 : 0xffffff8003616786
    0xffffff80f546be50 : 0xffffff800361831c
    0xffffff80f546be90 : 0xffffff8003635a40
    0xffffff80f546bed0 : 0xffffff80039556a7
    0xffffff80f546bf40 : 0xffffff8003955449
    0xffffff80f546bf50 : 0xffffff80039e063a
    0xffffff80f546bfb0 : 0xffffff80036cdd23
    BSD process name corresponding to current thread: ubd
    Mac OS version:
    12D78
    Kernel version:
    Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64
    Kernel UUID: 3EB7D8A7-C2D3-32EC-80F4-AB37D61492C6
    Kernel slide:   �... [Show more]

    Read other 15 answers

  • InvokeEvent.INVOKE re-dispatches when I close the application and I launch by multitask button

    Hello,
    on my galaxy nexus, Android 4.1, InvokeEvent.INVOKE re-dispatches when I close my application with
    NativeApplication.nativeApplication.exit()
    and I launch my application with the multi task manager.
    When I launch my application with the application icon, I don't have this problem.
    Thanks.

    It isn't a bug, it's the default behavior for android.
    <activity android:launchMode="singleTop">
              <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
              </intent-filter>
              <intent-filter>
                        <action android:name="android.intent.action.VIEW"/>
                        <category android:name="android.intent.category.BROWSABLE"/>
                        <category android:name="android.intent.category.DEFAULT"/>
                        <data android:scheme="mycustomuri"/>
              </intent-filter>
    </activity>
    the solution is to add android:launchMode="singleTop" in the application descriptor

  • Quickie - Stopping JFrames from minimizing when you close a dialog?

    Hi,
    As the subject bar suggests, there is probably a very quick solution to this:
    When I close dialogs that I have open, the parent JFrame minimizes to the taskbar. Its a bit annoying having to click on the taskbar to maximize it again. Is there a way of stopping this from happening? Thanks.

    Actually, you're right. After a little investigation, it was the way I was using the gui that was making this happen. During debuging (using Netbeans) I would open the dialog window then click on netbeans to check the console for a couple System.out.println()'s I put in the code. Then on closing the Dialog window Netbeans would be the next window selected by the OS and would appear over the original JFrame. D'oh! Just sillyness on my part imagining problems for myself.
    I guess what I was looking for was that when I close the dialog window that the OS would focus to the parent JFrame instead of the previously viewed application.
    Thanks!

  • Very annoying that the browser close when you close the tab !

    I have been using Opera browser for years now, and I could close all tabs without closing the browser, so why is Firefox made so it Closes the browser when the last tab is closed ?, it is soooooo very much annoying !

    Hello DKfire,
    You can use this addon :
    ''Shows the "Close" button on the last tab in Firefox
    Customizable button behavior:
    - Open a blank tab or Speed ​​Dial / Fast Dial
    - Open the home page
    - Close the window''
    [https://addons.mozilla.org/fr/firefox/addon/last-tab-close-button/?src=search https://addons.mozilla.org/fr/firefox/addon/last-tab-close-button/?src=search]

Maybe you are looking for

  • Configuring toplink with EJB to transactional control "CMT"

    I try to use the EJB transaction CMT but I need to configure toplink to use a transactional control of my EJB container. some body knows how can i do this? and how can I configure the toplink to get JNDI datasource? Best Regards

  • Hotmail sign in page stays blank. Every other web site loads ok.

    The hotmail " sign in " page stays blank. All other web sites i go to load just fine. My security settings are set to "permanent private browsing mode" I have emptied cookies, the cache, have even tried safe mode, nothing seems to work. Previous vers

  • Buy Lightroom 5 - when Lightroom 6 is on its way?

    Hey everyone, I REALLY want to upgrade to Lightroom 5, but I've read that Lightroom 6 is due to come out in March. I'd rather get the 6, but don't want to have to arbitrarily wait two months just so that I don't have to pay for two upgrades. Does any

  • Translators

    Hello! I am running Appleworks 6.2.9 on Leopard 10.5.7. I downloaded a business template pack off the AWUG site, and I want to save an invoice template as a Word document to open on a PC. Isn't there a way to "Save As" a Word .doc format? I only have

  • Import help from Canon ZR850 to iMovie.

    I am trying to import video from my Canon ZR850 using a Firewire 800 cable. It is not being recognized at all. I have the camcorder on and it plugged into my MacBook Pro. When I open iMovie, it does not show the camera as an import option. Suggestion