gwtbootstrap/gwt-bootstrap — pull request #449 by vetrovosk (2013-10-30 19:38:36+00:00)
Title: Dropdown memory leaks

Hi,

In our heavy GWT application we have found that several detached DOM trees could not be garbage collected because of references to nodes of these trees from javascript and vise versa.

One of the leaks in question is caused by event listener on root ```html``` element created in [```Dropdown```](https://github.com/twbs/bootstrap/blob/v2.3.2/js/bootstrap-dropdown.js#L32) constructor. It seems that the listener is not needed because there already is similar [listener](https://github.com/twbs/bootstrap/blob/v2.3.2/js/bootstrap-dropdown.js#L164) on ```$(document)``` element. We've tried to fixed it with the following [commit](https://github.com/vetrovosk/bootstrap/commit/e10edbc0d4903f0cebf23dc069eaa2644acdd592).

Another leak is caused by jQuery mechanins -- it is stated in several [sources](http://stackoverflow.com/questions/1462649/jquery-memory-leak-with-dom-removal) that elements which were somehow accessed with jQuery should be detached from DOM by ```$(el).remove()``` call which also removes all event listeners from the element and element itself from ```jQuery.cache``` map.

Profiling our application with Chrome Developer Tools shows that proposed changes make detached DOM trees containing dropdowns be successfully garbage collected.

That also fixes #397.