我有两个非常简单的Web服务方法,我每秒使用json调用 在IIS中存在内存泄漏,w3wp进程每秒占用300-400k 可以做些什么来阻止泄漏?
方法如下:
[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(',');
}