css() leaky behaviour on Firefox 3?

css() leaky behaviour on Firefox 3?


Hi,
I recently discovered a rather strange behaviour under Firefox 3. I
have been able to reproduce it on Firefox 3.0.3, 3.1b1 as well as the
latest nightly build with TraceMonkey enabled. Neither Chrome, IE7,
nor Opera (9.62) exhibit this behaviour. It occurs when changing many
time the position of a large number of elements by modifying their CSS
attributes to generate an animation.
It's not exactly a memory leak because after some times ff3 seams to
detect it and frees the memory. But this garbage collection takes a
lot of CPU thus making the animation very laggy at the time it occurs.
This is the shortest code that I've been able to find that generate
this. I used as few jQuery functions as possible to isolate the
problem.
var counter = 0;
var id = setInterval("refresh()",30);
function refresh(){
    //This doesn't leak:
    /*
    counter++;
    var children = document.getElementById("ground").childNodes;
    for(i = 0; i < children.length; i++){
        if(children[i].style){
            children[i].style.left = ""+counter+"px";
        }
    }*/
    // But this does a lot!
    counter++;
    var children = document.getElementById("ground").childNodes;
    for(i = 0; i < children.length; i++){
        $(children[i]).css("left", counter);
    }
    // this just stops the animation after a certain time
    if(counter > 300 )clearInterval(id);
}
When running this simple example you'll see the memory used by Firefox
going up by 20 to 30mo in a mater of seconds. The full example (js
+html) can be find at http://gamequery.onaluf.org/ff3mljq/ it uses a
recent nightly build of jQuery but the exact same thing occurs with
1.2.6. Any Idea of what is going on here ? Is this a bug in firefox,
is there something I'm doing wrong in my code?