C# 调用Web服务时服务器端内存泄漏
我有两个非常简单的web服务方法,我使用json每秒调用一次 IIS中存在内存泄漏,w3wp进程每秒占用300-400k 怎样才能阻止泄漏 方法如下:C# 调用Web服务时服务器端内存泄漏,c#,web-services,memory-leaks,server-side,C#,Web Services,Memory Leaks,Server Side,我有两个非常简单的web服务方法,我使用json每秒调用一次 IIS中存在内存泄漏,w3wp进程每秒占用300-400k 怎样才能阻止泄漏 方法如下: [WebMethod] [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public List<StationStatus> GetAllStationsValues(string networkID ,string stationIDs
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public List<StationStatus> GetAllStationsValues(string networkID ,string stationIDs)
{
List<StationStatus> stationStats = new List<StationStatus>();
foreach (string stationID in stationIDs.Split(','))
{
if (Application[networkID + "-" + stationID] != null)
{
string[] vals = (string[])Application[networkID + "-" + stationID];
stationStats.Add(new StationStatus() { NetworkID = networkID, StationID = stationID, ComponentName = vals[0].Split(':')[0], LatestValue = vals[0].Split(':')[1], Status = "0" });////////
}
}
return stationStats;
}
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string GetValue(string networkID, string stationID)
{
int sec = DateTime.Now.Second;
if (Application[networkID + "-" + stationID] == null)
{
return "";
}
string[] compValues = (string[])Application[networkID + "-" + stationID];
string returnValue = "";
foreach (string compValue in compValues)
{
returnValue += compValue + ",";
}
return returnValue.TrimEnd(',');
}
[WebMethod]
[ScriptMethod(UseHttpGet=false,ResponseFormat=ResponseFormat.Json)]
公共列表GetAllStationsValues(字符串networkID、字符串StationId)
{
List stationStats=新列表();
foreach(stationID.Split(',')中的字符串stationID)
{
if(应用程序[networkID+“-”+stationID]!=null)
{
字符串[]VAL=(字符串[])应用程序[networkID+“-”+stationID];
stationStats.Add(新StationStatus(){NetworkID=NetworkID,StationID=StationID,ComponentName=vals[0]。拆分(':')[0],LatestValue=vals[0]。拆分(':')[1],Status=“0”})////////
}
}
返回站状态;
}
[网络方法]
[ScriptMethod(UseHttpGet=false,ResponseFormat=ResponseFormat.Json)]
公共字符串GetValue(字符串networkID、字符串stationID)
{
int sec=DateTime.Now.Second;
if(应用程序[networkID+“-”+stationID]==null)
{
返回“”;
}
字符串[]compValues=(字符串[])应用程序[networkID+“-”+stationID];
字符串returnValue=“”;
foreach(compValues中的字符串compValue)
{
returnValue+=compValue+“,”;
}
返回returnValue.TrimEnd(',');
}
尝试使用类附加到returnValue字符串。尝试使用类附加到returnValue字符串。什么是应用程序类和StationStatus类?你能为它们添加代码吗?什么是应用程序类,什么是StationStatus类?你能为他们添加代码吗?