Results 1 to 4 of 4

Thread: Destroying javascript object

  1. #1
    Ext User 72's Avatar
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default Destroying javascript object

    If i close contentPanel tab with close icon, is content panel destroyed (memory released) and what about any content under it? Is destroyed too?
    72

  2. #2
    Ext User 72's Avatar
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Lightbulb

    The question was if javascript can release memory, but after that i found this

    Setting an object reference null does not "null the object out" or "copy
    the object to /dev/null"... it sets that object reference to null. If
    that reference were the last reference to the object, the object is
    eligible for garbage collection. If that reference were not the last
    reference to the object, then the object is still reachable and will not
    be garbage collected.

    var objectToBeDestroyed = new Object();
    var anotherReference = objectToBeDestroyed;
    objectToBeDestroyed = null

    -objectToBeDestroyed- is not being "copied to /dev/null" because it is
    still reachable.

    Even adding:

    anotherReference = null;

    will not "null out the object", it simply makes the object unreachable
    and eligible for garbage collection. There is no guarantee that it will
    be garbage collected. In fact, in a short-lived script, the garbage
    collector may not run at all during the execution of the script although
    it's almost certain to run when the page is torn down (you close the
    browser or navigate away from the page).
    source: http://www.thescripts.com/forum/thread152552.html


    It means that no object is really released from Browsers memory, objects still exists and im aware of garbage. I have dynamicaly loaded tabs and after close i want to destroy object (release memory). But i dont need content panels still in memory but seems as only one solution (in that case)
    72

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    186

    Default

    No, clicking the close button does not remove the dialog from memory. To accomplish that, you would have to do something like:

    Code:
    // where el = content panel/dialog/tab/whatever
    el.on('hide', el.destroy);
    Read up on event listeners and the 'destroy' function in the docs.

  4. #4
    Ext User 72's Avatar
    Join Date
    Apr 2007
    Location
    Czech republic, EU
    Posts
    152

    Default

    Yep, that was first i tried (destroy() method) but it not remove panel from memory (object still exists) and depend on what i read i can say it is impossible in JavaScript
    72

Posting Permissions

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