This leak still exists in 1.3.2 :(

On Thursday, December 23, 2010 1:52:14 PM UTC-5, Luke Ehresman wrote:
>
> I have discovered what I believe to be a pretty serious memory leak in the 
> Request class.  My site has long-running scripts with large data payloads. 
>  So, a user may leave the page open for days at a time without reloading 
> the page.  During that time, the site makes many AJAX requests to my 
> server.  I've noticed that my browser (all browsers I've tested -- Chrome, 
> Safari, and Firefox) degrade pretty quickly and consume copious amounts of 
> memory within a few hours.
>
> After several days of debugging, I have identified that it's a problem 
> with the Request class in MooTools.  Here is a sample script to recreate 
> the problem:
>
> ---------------[ begin code ]----------------
> <!DOCTYPE html>
> <html>
> <head>
> <script src="
> https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools.js
> "></script>
> </head>
> <body>
>  
> <script type="text/javascript">
>     document.addEvent("domready", req);
>  
>     function req() {
>         new Request({
>             url: "/large_file.json", // a large JSON-encoded file, ~50k
>             onSuccess: success
>         }).get();
>     }
>  
>     function success(resp) {
>         setTimeout(req, 1000);
>     }
> </script>
>  
> </body>
> </html>
> ---------------[ end code ]----------------
>
> I have set the timeout to 1 second in order to speed up the process and 
> see the degradation more quickly. After just 1.5 minutes, here is the 
> memory usage with MooTools (as monitored by the Chrome profiler):  
> http://cl.ly/090p3k1Z3G26453l060N
>
> For kicks, I ported this to jQuery too, just to see if it was something 
> with my code.  After 2.6 minutes, jQuery still does not show this pattern (
> http://cl.ly/3m363A1X1r3P2f232p0R).  Here's the jQuery code:
>
> ---------------[ begin code ]----------------
> <!DOCTYPE html>
> <html>
> <head>
> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js
> "></script>
> </head>
> <body>
>  
> <script type="text/javascript">
>     $(req);
>  
>     function req() {
>         $.ajax({
>             url: "/large_file.json", // a large JSON-encoded file, ~50k
>             success: success
>         });
>     }
>  
>     function success(resp) {
>         setTimeout(req, 1000);
>     }
> </script>
>  
> </body>
> </html>
> ---------------[ end code ]----------------
>
> I have also implemented a solution using XHR directly, and it has even 
> better performance memory-wise than jQuery: 
> http://cl.ly/2E1i3f2H2T3b041S350S
>
> ---------------[ begin code ]----------------
>
> <script type="text/javascript">
>
>    document.addEvent("domready", req);
>
>
>    function req() {
>
>        var xhr = new Browser.Request();
>
>        xhr.open('GET', '/large_file.json');
>
>        xhr.onreadystatechange = function() {
>
>            if (xhr.readyState != 4) return;
>
>            setTimeout(req, 1000);
>
>        };
>
>        xhr.send();
>
>    }
>
> </script>
> ---------------[ end code ]----------------
>
>
> -- 
> Luke Ehresman
> l...@ehresman.org
> Tebros Systems, LLC - http://tebros.com
>

Reply via email to