locked
Client side memory leak RRS feed

  • Question

  • User673549258 posted

    Hi,

    I have currently the problem that a lot of my users have problems with the memory usage of their IE when they use my application. After a lot of samples and some research on google I didn't find a solution for my problem.

    I hope anyone of you can help me.

    About the application: *Grid = DataGrid
    I just have a simple grid with a lot of columns and few rows (about 50). The grid is within a updatepanel and that causes the problems I guess. Currently I have a sample which shows the problem really well. Of course it is not a really useful sample but it helps to reproduce the problem.
    It can be downloaded from my onedrive: https://onedrive.live.com/redir?resid=42A470EDA779AD47%21111
    Just page the grid about 10 times and you will see that the memory increases. In the sample project its about 80%-100% on IE11 Win8.1. Many of my users have IE9 where it is much worse (feedback of the users).

    Hopefully anyone knows what I'm doing wrong. Btw. using less columns or less data is at the moment no solution.

    Greets,
    Jochen

    Wednesday, April 16, 2014 12:59 AM

All replies

  • User-821857111 posted

    Have you thought of replacing the UpdatePanel with jQuery and using an HttpHandler to render just the DataGrid?

    Wednesday, April 16, 2014 3:11 AM
  • User673549258 posted

    Hi,

    thanks for that suggestion.
    I'm currently not sure if I can do that easily in my real application but I will try it in the sample to find out if that could solve the problem.

    Wednesday, April 16, 2014 3:11 PM
  • User-417640953 posted

    Hi Mr. Jochen,

    Thanks for your post.

    Based on your description, I think your client browser cache large data when load page many times.

    So I suggest you disable browser cache on ASP.NET pages by adding html header metatags like below.

     <meta http-equiv="Expires" content="0">
     <meta http-equiv="Pragma" content="no-cache">
     <meta http-equiv="Cache-Control" content="no-cache">
    

    Besides, I suggest you avoiding use the viewstate in your asp.net page if necessary.

    # Avoid using view state in pages that do not post back to the server, such as logon pages.

    # Avoid using view state for large data items, such as DataSets, because doing so increases time in roundtrips to the server.

    # Avoid using view state when session timeout is required because you cannot time out data stored in the ViewState property.

    And there ia an article about "Caching Architecture Guide for .NET Framework Applications", please check it.

    http://msdn.microsoft.com/en-us/library/ee817647.aspx

    Hope that helps, thanks.

    Best Regards!

    Wednesday, April 16, 2014 11:31 PM
  • User673549258 posted

    Hi,

    thank you for your answer. I have tried the metatags and it helps a bit. The start memory usage is about 10MB lower than before but the memory still rises that much during postbacks.

    I have disabled the viewstate in my sample project which had no effects on the issue. The ViewState usage in my sample project is not exactly the way how I'm doing it in my real application. Nevertheless, thanks for that link I've already started to use the Cache possibilities of ASP.NET more and more.

    I found out that in Chrome it works pretty well. In Firefox it is now ok, because of the metatags. So, is it possible that only IE has really big troubles with that? What do you think?

    Thursday, April 17, 2014 12:06 PM
  • User673549258 posted

    Have you thought of replacing the UpdatePanel with jQuery and using an HttpHandler to render just the DataGrid?

    I've now tried to implement your suggestion but there is one big problem where I don't know how to do that.
    Of course I can easily get the data and fill a datagrid with it but how can I render that without adding it to the controlcollection?

    Thursday, April 17, 2014 12:16 PM
  • User-821857111 posted

    You can add a Generic Handler to your app (ashx file) and then render the DataGrid in the ProcessRequet method:

    public class GridHandler : IHttpHandler
    {
    
        public void ProcessRequest(HttpContext context)
        {
            StringWriter textWriter = new StringWriter();
            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(textWriter);
            DataGrid dg = new DataGrid();
            dg.DataSource = GetData(); //specify the source of the data for the grid here
    
            dg.DataBind();
            dg.RenderControl(htmlTextWriter);
    
            context.Response.Clear();
    
            context.Response.Write(textWriter.ToString());
            context.Response.End();
        }
    
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

    Thursday, April 17, 2014 4:59 PM
  • Wednesday, April 23, 2014 8:45 AM
  • User673549258 posted

    You can add a Generic Handler to your app (ashx file) and then render the DataGrid in the ProcessRequet method:

    Thanks for your code snippet. I have added it and implemented a manual get of the data with jquery. Unfortunately this doesn't solve the problem. It still has problems with the amount of data. Furthermore it does not work better than the standard updatepanel.

    Thursday, April 24, 2014 3:46 AM