jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox destory leaving DOM elements behind

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • pguz
    Participant

    Hi,

    Checking memory usage in my app, I’m finding my ListBoxes are leaving many DOM elements in memory after calling destroy.

    There may be something else holding references to them, so I tried a vanilla example. Take heap snapshots in Chrome Dev Tools using the following fiddle and you will see a few HTML elements remaining after destroy is called.

    http://jsfiddle.net/x7wutwxe/

    This is fewer than I see in my application, but is this appears to be evidence that destroy is not completely cleaning up the widget.

    Paul

    destory leaving DOM elements behind #71114

    Peter Stoev
    Keymaster

    Hi Paul,

    Take a look at your DOM. No Element from jqxListBox is in the DOM after Destroy. Browsers garbage collectors decide on their own when to release their memory, but all it depends on us is removed!

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    destory leaving DOM elements behind #71116

    pguz
    Participant

    Peter,

    I beg to differ – there are additional elements shown in the Profiler, having taken snapshots before creating the ListBoxes, and after destroying, and these have jqx classes. There is also nothing else on the page that would be adding or removing DOM elements.

    I’d include a Profiler screenshot showing an Input element from the listbox (the filter box assumedly) but there is no way to do so on this forum. I could email it to you if you like.

    To reproduce, open the fiddle, take a Heap Snapshot in Profiler, click Create, take another snapshot, click Destroy, take a third snapshot. Compare Snapshot 3 to 1 and you will see +5 HTMLDivElements. Expand the Detached DOM Tree to see the jqx elements.

    Paul

    destory leaving DOM elements behind #71117

    Peter Stoev
    Keymaster

    Hi Paul,

    Open your DOM Explorer and see what’s left after destroy. The result is nothing. I don’t have to take snapshots or anything else. The browser will call it’s garbage collector and will collect the garbage when it needs to.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.