在我的MVC應用程序中,我每10秒使用一次重複的ajax調用。有時在數據庫服務器與應用程序服務器斷開連接之後,應用程序正在運行的瀏覽器中存在大量內存泄漏。由於重複ajax調用,內存泄漏和DB服務器連接失敗
我的代碼運行的,
我使用jquery.timer.js重複Ajax調用,每10秒
function class1() {
}
class1.prototype. funtion1 = function() {
$.ajax({
type: "POST",
url: "/TestContoller/ActionOne",
success: function (result) {
$('#DivActionOne').html(result);
},
traditional: true,
error: function (req, status, error) {
}
});
}
//Likewise for funtion2, funtion3, funtion4, funtion5
var count = 0;
var timer = $.timer(function() {
$('#counter').html(++count);
var class1 = new class1();
var funtionOne= class1.funtion1;
var funtionTwo= class1.funtion2;
var funtionThree= class1.funtion3;
var funtionFour= class1.funtion4;
var funtionFive= class1.funtion5;
var currentSec = count;
if ((currentSec % 10) == 0) {
funtionOne();
funtionTwo();
funtionThree();
funtionFour();
funtionFive();
}
});
timer.set({ time: 1000, autostart: true });
當連接丟失了我檢查跟蹤日誌,發現下面的錯誤消息:
消息:System.ServiceModel.CommunicationException:底層連接已關閉:預計將保持活動的連接已被服務器關閉。 ---> System.Net.WebException:底層連接已關閉:服務器關閉了預期保持活動狀態的連接。 ---> System.IO.IOException:無法從傳輸連接讀取數據:現有連接被遠程主機強制關閉。 ---> System.Net.Sockets.SocketException:現有連接被遠程主機 強制關閉在System.Net.Sockets.NetworkStream.Read(Byte []緩衝區,Int32偏移量,Int32大小) --- End內部異常堆棧跟蹤--- at System.Net.Sockets.NetworkStream.Read(Byte [] buffer,Int32 offset,Int32 size) at System.Net.PooledStream.Read(Byte [] buffer,Int32 offset,Int32大小) 在System.Net.Connection.SyncRead(HttpWebRequest請求,布爾userRetrievedStream,布爾probeRead) ---內部異常堆棧跟蹤--- 結束在System.Net.HttpWebRequest.GetResponse() 在System.ServiceModel .Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超時) --- End of end異常堆棧跟蹤---
請幫我整理一下。
更新與跟蹤日誌的問題。 –