Memory Leaks in jQuery UI

I have a simple page that consists of a table with three jQuery UI progressbars and an ajax call. The ajax calls out to an empty php file and on success I destroy and recreate my progressbars. It seems simple but running it caused memory leaks in both IE7 and Chrome (although Chrome handled it much more gracefully). Here's my code:

<script type="text/javascript" src="jQuery/js/jquery-1.3.1.js"></script> <script type="text/javascript" src="jQuery/js/plugins/jquery-ui-1.6rc4.min.js"></script> <link rel="stylesheet" type="text/css" href="jQuery/css/ui.all.css" /> <script type="text/javascript"> $(function(){ timed(); }); function timed() { $.ajax({ url: "index.php", success: function(msg){ $(".progressbar").progressbar("destroy").progressbar(); } }); setTimeout("timed()",1000); }

<table> <tbody> <tr> <td> <div class="progressbar"></div> </td> <td> <div class="progressbar"></div> </td> <td> <div class="progressbar"></div> </td> </tr> </tbody>

Any ideas for what I'm missing here? I've tried adding $("*").unbind(); before the $(".progressbar") line in my Success function.

-------------Problems Reply------------

Why are you destroying then recreating it? Wouldn't it be simpler to just reset the progress values to zero and leave it alone until you need it again later. You can even .hide() it if you specifically don't want it visible.

I think what I'll do is just create the progress bar at the application start, clone it, and add it to my template after its finished processing. This essentially slows the memory usage to a crawl (about 4k every 4-5 refreshes) rather than the current (about 100 to 300 k per refresh).

Category:jquery ui Views:0 Time:2009-02-05

Related post

  • Memory leaks with jQuery in IE 7/8/9 and FF 4 2011-06-12

    I have been struggling with some memory leaks using jQuery in all major browsers, and am looking for some help. I've read many articles on memory leaks, references, circular references, closures, etc. I think I'm doing everything right. But am still

  • Memory leak involving jQuery Ajax requests 2009-09-21

    I have a webpage that's leaking memory in both IE8 and Firefox; the memory usage displayed in the Windows Process Explorer just keeps growing over time. The following page requests the "unplanned.json" url, which is a static file that never changes (

  • Memory Leak with jQuery UI inside UpdatePanel in ie7 2010-02-06

    I have a fairly complex page based on UpdatePanels and jQuery UI. Unfortunately, when the panels update, the jQuery UI widgets leak memory like crazy in ie7, even if I manually 'destroy' them. Does anyone know a technique/patch to prevent the

  • How likely are memory leaks with jQuery? 2011-03-21

    Imagine, I build a complex interface using jQuery/AJAX and want the application with this interface to be open during all day long. It deals heavily with AJAX, builds its elements, removes others, changes positions and sizes etc. How likely are memor

  • JavaScript memory leak in jQuery plugin 2011-12-19

    I have a plugin with the following structure: (function($) { $.fn.drawFieldsTable = function(options) { var settings = { url : 'ajax/pathToFile.php' }; if (options) { settings = $.extend(settings, options); } return this.each(function() { $this = $(t

  • memory leak with jquery remove()? 2012-01-12

    Possible Duplicate: jQuery memory leak with DOM removal I created a simple javascript code snippet to test memory leak. function createDom(howmany) { var i; var el; var body = $("body"); for(i=0;i<howmany;i++) { el = $("<div></div>");

  • What are some common ways to cause memory leaks using JQuery/JavaScript? 2012-04-25

    My question assumes you are creating a web page that will be displayed for a "long time." I'm curious as to what are some of the common gotchas that will cause memory leaks when using JQuery/JavaScript in such a scenario? For instance what happens in

  • Memory leak with jQuery ajax (json) calls 2010-11-05

    I'm making a web browser based real time game. I'm using jQuery ajax calls to call a web service method for the client to update their speed & location via json data. Returned is a list of strings which contain data for the locations and speeds o

  • How can I control IE6+jQuery+jQuery-ui memory leaks? 2009-06-26

    Here's a sample page with a couple datepickers. Here's the Drip result for that: This page leaks indefinitely in IE6sp1 when I click the Refresh button repeatedly (IE6sp3+, Opera 9, Chrome2, and FF3+ seem to be good). The memory goes up and never goe

  • Using jQuery and Memory Leaks 2011-03-11

    I have been using jQuery for over a couple of months and read up on Javascript memory leaks for a few days. I have two questions regarding memory leaks and jQuery: When I bind (using .bind(...)) do I have to unbind them (.unbind()) if I leave the pag

  • What sort of memory leaks should I watch for with jQuery's data()? 2009-06-29

    Should I pair every data() call with a later removeData() call? My assumptions: jQuery's remove() will remove elements from the DOM, and if I don't have any other references to remove, I don't have to do any more clean up. However, if I have some jav

  • On jquery, closures, and possible memory leaks 2009-07-27

    I've read quite a bit about how memory leaks are created in various versions of IE. Some great information can be found here: Using

  • jQuery memory leak with DOM removal 2009-09-22

    Here's a dead-simple webpage that leaks memory in IE8 using jQuery (I detect memory leaks by watching the memory usage of my iexplore.exe process grow over time in the Windows Task Manager): <html> <head> <title>Test Page</title

  • jQuery load() method memory leak? 2010-01-29

    I have hunted around for answer to this one, and though have found related quesions, I couldn't quite find an exact match for this. I have a fairly large app which is supposed to load pages into divs in another page using the jQuery.load() method. Th

  • Why .data() function of jQuery is better to prevent memory leaks? 2010-04-30

    Regarding to jQuery utility function the online documentation says: "The method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks. " Why to

  • jQuery Ajax Memory Leaks 2010-07-15

    I've seen some other posts on this, but it appears that when i do ajax calls with jquery over and over again (every 30 seconds in my case), I get a memory leak. Changing from a $get to a $post (whilst more secure as well) cuts down on the size - it s

  • Javascript / jQuery - How do I find the memory leak in my large amount of code? 2010-08-12

    I've written a lot of code for a website I'm developing and only just now realised it has a memory leak. I noticed Firefox getting rather slow over the day and checked my task manager to find it idling at 600,000 K. Seemed odd and so I killed it/rest

  • Where is memory leak in JavaScript / jquery? 2010-09-23

    I have two singletons: Search - performs the search functionality Topic - presentation of topics (search results) var Search = new function () { this.GetTopics = function () { var query = $("#globalSearch").val(); $.ajax({ url: 'Search/GetTopics', da

  • Memory Leak When Using jQuery .Get API and setTimeout 2011-01-21

    I am using jQuery 1.4.4 and use the .get API to check to see if I need to refresh data on a page or not. The problem is that there is a memory leak somewhere in the snippet below that I cannot seem to find. You will notice that I do a lot of potentia

Copyright (C), All Rights Reserved.

processed in 0.292 (s). 11 q(s)