Beau Hartshorne wrote:
> Good question, I don't know. In theory, Signal does not require
> disconnect to be called -- it does this for you when the page closes.
> But once you get into tricky stuff like this, it might leak. If
> you've got access to IE, please do me a favor and test this code in
> drip, and let me know how it goes.
>
> Thanks!

I did not try on IE, but the following test shows the problem on
Firefox. Without disconnect, mem usage goes up until the page
is closed; with disconnect, mem usage fluctuates but it does not
seem to grow (gc at work, probably). So as I feared, DOM signals
must be disconnected before discarding DOM elements.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
    <title>Signal Test</title>
    <script type="text/javascript"
src="../MochiKit/MochiKit.js"></script>
</head>
<body>
   <div id="main"/>
</body>
<script type="text/javascript">

    function click(e) {
        alert("click!");
    };

    i = 0;

    function exp(n) {
       var r = "A long string to make it leak faster if it should... ";
       while(n--) {
          r = r + r;
       }
       return r;
    };
    a = exp(10);

    function loop() {
        i += 1;
        var m = DIV(null, "iteration" + i + ". " + a);
        connect(m, 'onclick', click);
        // disconnect($('main').childNodes[0], 'onclick', click);
        replaceChildNodes('main', m);
        callLater(.1, loop);
    }

    function start() {
        var m = DIV(null, "iteration" + i + ". " + a);
        connect(m, 'onclick', click);
        replaceChildNodes('main', m);
        loop();
    }

    start();
</script>
</html>

Eric.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to