Hello,
I got one question, that may seems trivial to you, but I really dont
understand it. Let's say we got this code:
function ajax()
{
var obj;
obj = new ActiveXObject("Microsoft.XMLHTTP");
obj.onreadystatechange = function ()
{
[anycode];
};
obj.open("GET", "http://www.park.sk", true);
obj.send(null);
}
(for simplicity i created XHR just for IE as activex). As far as I
know, browsers's garbage collector should discard all function's local
variables after functions exits, if none of inner objects (variables)
got reference out of that function. But as we all know, XHR object
persists in memory and becuase it refers to locally created function
(onreadystatechange), all local varibales stay in memory as well
(because of closures). But why does garbace collector not discard
activex object after function ajax exits? It does not have any
reference out of that function's scope.
It looks like that browser creates some hidden reference to that
activex object AFTER i call "send" method (so browser wont discard
it), and delete that reference after XHR objects's state change to
LOADED.
Please make it clear to me. I really cant find the answer.