在我的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异常堆栈跟踪---
请帮我整理一下。
更新与跟踪日志的问题。 –