views:

49

answers:

1

I have built a suite of internal websites for our company to manage some of our processes. I have been noticing that these pages have massive memory leaks that cause the pages to be using well over 150mb of memory, which is ridiculous for a webpage that consists of a single form and a GridView that is displaying 7-10 rows of data at a time, sometimes with the data not changing for a whole day. This is an issue because it is slowing down our client machines due to lack of available memory.

After some testing it appears that the memory leak is extremely easy to reproduce, and very noticeable. I created a page with the following asp.net markup:

<body>
<form id="form1" runat="server">
<div>
    <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>    
    <asp:Timer ID="timer1" runat="server" Interval="1000" />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    </ContentTemplate>
    </asp:UpdatePanel>
</div>
</form>
</body>

There is absolutely no code behind for this. This is the entirety of the page. Running this site in Chrome shows the memory usage shoot up to 25 megs in the span of 20-30 seconds. Leaving it running for a few minutes makes the memory go up to the 70 megs and such.

Am I using timers and update panels wrong, or is this a pure Asp.net issue with no work around?

Note: I am not talking about memory used on the server, I am talking about memory used on the client.


Edit: Well it looks like this is an issue with Chrome. Firefox and IE8 do not seem to have any memory issues while running this page for a long period of time.

+1  A: 

.NET isn't necessarily using all that memory. See http://stackoverflow.com/questions/357675/how-can-i-determine-how-much-memory-my-net-program-is-using

I read a really good article about it once but I can't find it now. I'll update this answer if I do.

Edit: Here's a good one: http://blogs.msdn.com/b/tess/archive/2006/09/06/742568.aspx And one more: http://www.getdotnetcode.com/gdncstore/free/Articles/The%20Memory%20Mystery.htm

Nelson
I'm not talking about memory on the server. I am talking about memory on the client.
KallDrexx
@KallDrexx - Oh, you mean Chrome is using that amount of memory? Try minimizing Chrome and see if the memory drops. It could still be similar behavior as the links I provided. Also, try a different browser to see if you have the same memory issues. I'll give it a try on my end as well.
Nelson
Added edit to my original post. It seems to only be an issue in Chrome, not FF or IE8. Interesting.
KallDrexx
@KallDrex - IE 8 doesn't have its memory shoot up. However, generally browsing around increases the Private Working Set and it doesn't come down again. It doesn't mean it's actually using all that. I'm not sure I can really answer this...
Nelson
@KallDrexx - Yeah, I wouldn't call it an "ASP.NET memory leak" since the browser is really handling the memory. ASP.NET simply sends HTML and JavaScript ("text") along. I think the closest you could come is if the ASP.NET ViewState was increasing indefinitely, but then it's technically not a memory leak.
Nelson
@KallDrexx - Simply opening up Chrome (latest 5.0.375.70) to google.com uses up 40MB on my machine (Windows 7). I'm seeing the memory jump up and down, but no apparent "leak".
Nelson
Well I meant the asp.net control has a memory leak (the control's generated javascript at least). However, this is not a viewstate issue as I am watching the viewstate and the viewstate is staying the exact same each update.
KallDrexx
In Win 7 here at work, my chrome process at google.com uses 9MB of memory in 5.0.375.70
KallDrexx
Note that the 40MB I'm seeing is across two different chrome.exe processes that start up. Anyway, I don't know how to fix this. I'm guessing it's a problem Chrome would have to fix.
Nelson