I have some problems with javascript memory leaks.
I am using them that show me Javascript objects that are still in memory.
Now I am not sure how to open the DOM object correctly with the event etc. For example, I have a jQuery widget called 'Drop Down Box'. In the way of destroying, I make all the necessary things to open event-handlers like:
this.box.find ('toggler'). Unbind (); This.box.remove (); This.box = null;
These 3 lines are required, or is it possible to call only. Box.remove ()?
To date, I've never unbounded DOM elements because I thought it did not make any difference but I came with the problem, after 2 hours of developing on the same site, my Firefox 1 GB consumes!
So I read some memory leaks while using Closer etc. Second question: I use to shut down very often because they are really cool and easy.
Some people say that you should not use closor for everything, for example if we have the following code:
function foo (param1, param2) {var local1 , Local2; $ ('A'). Click (function () {Alert ('YEAH');}); }
It would be better to do this:
funtion foo (param1, param2) {var local 1, local 2; . Click on $ ('one') (clickEvent); } Function () {alerts ('yeh'); }
Am I misunderstood?
You just call:
this.box.remove ( ); This.box = null;
will also be there. The final step is to delete the element completely removed out of context by .box
( and do not believe anything to handle it). Your second example, the second version is a little more efficient because the handler has not been copied everywhere, the larger the handler, the more it makes a difference.
Comments
Post a Comment