0
我有一個相當複雜的基於UpdatePanels和jQuery UI的asp.net頁面。不幸的是,當面板更新時,即使我手動「銷燬」它們,jQuery UI小部件也會在ie7中像瘋了一樣泄漏內存。有誰知道一種技術/補丁來防止這些泄漏?我在UpdatePanel中創建了一個帶有滑塊的簡單示例頁面。只需點擊'泄漏'按鈕並刷新頁面以查看篩中的泄漏。IE7中的UpdatePanel內的jQuery UI內存泄漏
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Leak2.aspx.cs" Inherits="Leak2" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Leak</title>
<link type="text/css" href="/jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="/jquery/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function initializeSlider() {
$(".slider").slider({
min: 0,
max: 100,
value: 100,
step: 5
});
}
$(document).ready(function() {
initializeSlider();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() {
initializeSlider();
});
});
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width: 300px;">
<div class="slider"></div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Leak" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
從來沒有聽說過jQuery的內存泄漏! – 2010-02-06 17:40:09