View Full Version : IE: where's my memory?
Valera
1 Sep 2007, 4:09 AM
http://www.bazon.net/mishoo/articles.epl?art_id=824
Comments?
Animal
1 Sep 2007, 4:13 AM
I have a script that creates 3000 SPAN elements and assigns an “onclick” event handler for every one.
Comments?
How about, "That's a pretty crap thing to do".
Animal
1 Sep 2007, 4:18 AM
span.onclick = function() { alert(this.innerHTML); };
Is not a circular reference. "this" is not indelibly assigned at the time the closure is created, it is assigned dynamically when the function is called.
mystix
1 Sep 2007, 4:22 AM
/:) what the heck is this doing in bugs?
@valera: 8887
read before posting your next "bug"
Animal
1 Sep 2007, 4:22 AM
The IE memory leak is one of the reasons for http://extjs.com/deploy/ext/docs/output/Ext.html#enableGarbageCollector
Animal
1 Sep 2007, 4:23 AM
Yes, it's more a "General Discussion" thread.
mystix
1 Sep 2007, 4:25 AM
[ moved to General from Bugs... /:) ]
Valera
1 Sep 2007, 6:58 AM
http://test.f-studio.info/nodes.html
mystix
1 Sep 2007, 7:22 AM
and your point is?
it's kind of tough discussing a misplaced one-liner (i.e. your first post) and a flash video showing some massive DOM leaks (i.e. your last post).
p.s. nice and clear flash vid btw. what software did you use for the capture?
Valera
1 Sep 2007, 7:39 AM
and your point is?
it's kind of tough discussing a misplaced one-liner (i.e. your first post) and a flash video showing some massive DOM leaks (i.e. your last post).
p.s. nice and clear flash vid btw. what software did you use for the capture?
BB FlashBack
Drip-0.5
Valera
1 Sep 2007, 7:42 AM
p.s. nice and clear flash vid btw. what software did you use for the capture?
BB FlashBack http://www.freedownloadscenter.com/Authors/Blueberry_Consultants_Ltd.html
mystix
1 Sep 2007, 7:43 AM
alright enough with the with 1-liners already.
speak your mind.
Valera
1 Sep 2007, 7:53 AM
alright enough with the with 1-liners already.
speak your mind.
if there was a decision I would state it, it would be desirable to find the decision of the given problem...
mystix
1 Sep 2007, 7:59 AM
/:)
zlsergey
1 Sep 2007, 8:01 AM
http://test.f-studio.info/nodes.html
At me the same problems. :-?
Interestingly that developers think in this occasion?
Whether work on elimination of these problems Is conducted?
P.S. enableGarbageCollector and enableListenerCollection do not help with these problems.
Memory Leak is an IE's "feature". Don't matter what you do, it's there! I spent four days (Mystix knows) to understand it. Same on www.start.com (http://www.start.com), the IE Leak is there
http://extjs.com/forum/showthread.php?t=11810&page=2
What can we do ? Say to users don't use IE ? Well... If you can't beat them, join them!
Practice things to avoid memory usage:
- Try re-use all forms/shim/dialogs
- Change remove() Element method to "remove" with removeNode() instead of removeChild() on IE
- Comment the opacity on css (like filter:alpha(opacity...))
- Null the setOpacity method to IE
Some code:
removeNode() instead of removeChild()
Ext.override( Ext.Element, {
remove: function() {
var El = Ext.Element;
if( Ext.isIE )
{
this.dom.removeNode(false);
} else {
if(this.dom.parentNode) this.dom.parentNode.removeChild(this.dom);
}
delete El.cache[this.dom.id];
}
});
Tell to IE ignore the setOpacity
Ext.override( Ext.Element, {
setOpacity: function( opacity, animate )
{
if(!animate || !A) {
var s = this.dom.style;
if( !Ext.isIE ) s.opacity = opacity;
} else {
this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn');
}
return this;
}
});
zlsergey
1 Sep 2007, 11:14 PM
For Firefoks this code causes a error. And for IE I have not noticed essential changes - memory grows all the same rates: (
Foggy
20 Sep 2007, 1:44 AM
Please read this ms explanation
http://msdn2.microsoft.com/en-us/library/Bb250448.aspx
And there circulate many solutions for this with a closure prototype
http://www.google.ch/search?hl=de&q=Function.prototype.closure&btnG=Suche&meta=lr%3D
steffenk
20 Sep 2007, 2:58 AM
may be this little function helps for that problem (found on selfhtml)
function.prototype.closure = function() {
if(!window.__funcs) window.__funcs = [];
window.__funcs.push(this);
return function () {
return window.__funcs[window.__funcs.length - 1].apply(null, arguments);
};
};
Foggy
20 Sep 2007, 3:55 AM
Maybe but the biggest problem i see on this solution, is the fact that you have to call any function on a event like this:
button.on("click", clickHandler.closure);
steffenk
20 Sep 2007, 3:58 AM
i don't think this has to be done on every action, but indeed some times. Could this be a job for the TaskManager ?
removeNode() instead of removeChild()
Ext.override( Ext.Element, {
remove: function() {
var El = Ext.Element;
if( Ext.isIE )
{
this.dom.removeNode(false);
} else {
if(this.dom.parentNode) this.dom.parentNode.removeChild(this.dom);
}
delete El.cache[this.dom.id];
}
});
This seems to cause a problem with the grid menu for columns in IE6. The first time expanded the columns list is fine, but subsequent times there is a problem. I am guessing to the using of this.dom.removeNode(false). Please see attached.
BTW - I see you're using Drip - Give sIEve a shot. I like it a bit better. (http://home.orange.nl/jsrosman/)
I ran into these issues awhile back...I got real close to completely cleaning up the DOM and memory after creating a basic dialog, but it was a lot of trial and error and I eventually gave up after realizing I'd have to figure that out for everything I put in the dialog as well.
I did notice that 2.0 seems to clean up after itself better than it used to though.
tjcrowder
14 Oct 2007, 1:39 AM
span.onclick = function() { alert(this.innerHTML); };
Is not a circular reference. "this" is not indelibly assigned at the time the closure is created, it is assigned dynamically when the function is called.
Ah, but it is. The fact that the function doesn't use the span variable doesn't mean it doesn't keep the execution context in which it was created alive. It does. JavaScript is so dynamic that the engine can't know for sure that the function isn't going to find a way to use span. Any function inherits (and keeps alive) all of the parameters and variables of the function in which it was created. Like Bazon, I came up with this metaphor of using a temporary anonymous function to create and return the event handler in hopes that since the temporary function goes away, it doesn't preserve the context, but I haven't proved yet that it has the desired effect. I'm hoping his exploration in that page is proof. :) More on this stuff here: http://www.crockford.com
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.