Ask a questionAsk a question
 

QuestionThe memory leaks of UpdatePanel

  • Monday, July 27, 2009 2:56 AMArcher Chen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    We find a strange memory leak of UpatePanel.

    Create a Aspx page. Add a ScriptManager component. Add an UpatePanel. Add a button into UpdatePanel. Call ScriptManager.RegisterStartupScript(this, this.GetType(), this.ClientID, jsText, true) in click event of this button.

    In order to get an obvious result, we use key word "new" or $Create() to create a big javascript object in that jsText. For example, that js object has a large json data, which's length is 20000 at least.

    Click that button again and again. That js object will be dispoed and created again and again. Using sIEve and Microsoft JSLeakDetector, we cannot find any memory leak. But you can see the memory size of you IE Browser increase constantly.

    Our js object is very simple :

    Type.registerNamespace("Test");
    Test.TestControl = function(data)
    {
        this._data = data;
    }

    Test.TestControl.prototype =
    {
        initialize: function()
        {
            Test.TestControl.callBaseMethod(this, 'initialize');
        },

        dispose: function()
        {
            delete this._data;
        },

        get_data: function() { return this._data; },
        set_data: function(value) { this._data = value; }
    }

    Test.TestControl.registerClass('Test.TestControl');

    The increased size of memory is decided by the size of data.
    We test it in IE7 and IE8. They all have memory leaks, despite ScriptManager.ScriptMode = Debug or Release.

    We find Sys._ScriptLoader run js by insert a script element into header and remove it quitely.  In debug mode, it never be removed. Though it is removed in release, the memory size increases as usual.

    Can you help me to solve this problem ?

All Replies

  • Wednesday, August 12, 2009 6:43 AMMSMit Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Not sure whether relevant in your case

    http://www.codeproject.com/KB/ajax/jqmemleak.aspx
  • Thursday, November 05, 2009 10:02 PMChuckie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm experiencing increased memory usage in IE... using the updatepanel. I believe it's references to dom objects that are not being disposed of when the UpdatePanel fires.