page explodes memory usage to 80MB and then dies
I'm using asp.net and chrome and the page becomes unresponsive after a while. When I look at the chrome debug, I see that memory usage increases to about 80MB and chrome popups a request to kill the page. The error counter spins and generates about 30,000 errors when the popup comes. What triggers the error is the call of an updatepanel. The error as displayed in chrome is "Failed to load resource".
The update panel: the user clicks on a button and the panel is refreshed. There's only one update panel on the page.
This is what I have:
function HistoryUIActions() {
$('.SelectDay, .SelectDay1Digit').click(function () { GetNewDate(this); });
};
function GetNewDate(thedateitem) {
var TheDay = $.trim($(thedateitem).html());
TheYear = 2011;
ThisMonth开发者_高级运维 = 2;
DateString = ThisMonth + '/' + TheDay + '/' + TheYear;
__doPostBack('<%= TheUpdatePanel.ClientID %>', DateString);
};
function EndRequestHandler(sender, args) {
HistoryUIActions();
};
The errors compound on every postback: 1,4, 11, 26, 57, 120, 247.... eventually chrome kills the page. When I put a breakpoint in the function, it stops the code just after I press the button; then after it hits the __doPostBack line, it starts the GetNewDate function again several times by going back to the line of the click event, apparently executing it the number of times shown above.
Any suggestions?
Duh. :) After looking at this a dozen times, I think I have the answer, or at least part of it.
Your click control is outside the updatepanel. Yet you call "HistoryUIActions" to bind the click event with jQuery after each refresh. This will double the number of click events bound to your control every time you click it.
Click handlers are cumulative. You don't need to rebind it, unless the actual DOM element of the control has been re-rendered. Each time you click you are adding a duplicate handler.
This ought to solve the multiple-refresh problem, then you can figure out what's not loading properly after a click.
精彩评论