30个用户并发压力测试的时候,前20分钟,内存占用都正常,20分钟以后,内存狂飙,一直到内存消耗完为止。
如果 我在 "断点位置"直接返回,压力测试内存消耗正常。
测试时候,反射类里面不执行任何东西,就写了一个空函数,return "";
各位高手请帮忙,谢谢,分数不够在加。
从 FormDataCheck()方法开始调用。
public ArrayList FormDataCheck()
{
string strCheckErr = "";
bool CheckResult = false;
ArrayList arrResult = new ArrayList();
try
{
ArrayList dsItems = new ArrayList();
if (this.isinterface)
{
dsItems = this.datasetitems;
}
else
{
for (int i = 0; i < this.tables.Length; i++)
{
DataSet ds = GetData(tables[i]);
if (ds != null)
{
dsItems.Add(ds);
}
}
}
ReflectFormat reformat = new ReflectFormat();
DataCheckDef ckDef = new DataCheckDef();
DataCheckDef DataCheckDef = new DataCheckDef();
ArrayList CheckItemList = ckDef.GetCheckConfig(this.wm_guid);
if (CheckItemList.Count > 0)
{
DataCheckDef = (DataCheckDef)CheckItemList[0];
}
reformat.ReflectDLLName = DataCheckDef.CheckReflectDll;
string[] reflectArr = DataCheckDef.CheckReflectMethod.Split('|');
//断点位置
if (reflectArr.Length >= 3)
{
reformat.NameSpace = reflectArr[0].ToString();
reformat.ClassName = reflectArr[1].ToString();
reformat.Method = reflectArr[2].ToString();
Reflect reflect = new Reflect();
//反射调用
strCheckErr += (string)reflect.ReflectMehod(reformat, this.tables, dsItems,
this.wm_guid, this.isinterface);
}
if (strCheckErr != "")
{
InsertLog(strCheckErr);
UpdateState();
CheckResult = false;
}
else
{
CheckResult = true;
}
arrResult.Add(CheckResult);
arrResult.Add(strCheckErr);
dsItems.Clear();
dsItems=null;
}
catch (Exception ex)
{
}
return arrResult;
}
//反射类定义
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Web.UI;
using System.Web;
namespace BizReflectWork
{
public class ReflectFormat
{
string reletivePath = "";
public string ReletivePath { get { return reletivePath; } set { reletivePath = value; } }
string dllName = "";
public string ReflectDLLName { get { return dllName; } set { dllName = value; } }
string nameSpace = "";
public string NameSpace { get { return nameSpace; } set { nameSpace = value; } }
string className = "";
public string ClassName { get { return className; } set { className = value; } }
string method = "";
public string Method { get { return method; } set { method = value; } }
}
class Reflect
{
#region 调用反射
PublicMethod pm = new PublicMethod();
private Type GetAssemblyType(ReflectFormat refFormat)
{
string strparth = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "Bin\\" + refFormat.ReflectDLLName;
if (!System.IO.File.Exists(strparth))
return null;
Assembly MyAssembly = Assembly.LoadFrom(strparth);
Type t = MyAssembly.GetType(refFormat.NameSpace + "." + refFormat.ClassName);
return t;
}
/// <summary>
/// 反射执行dll
/// </summary>
/// <param name="refFormat"></param>
/// <param name="tables"></param>
/// <param name="dsItems"></param>
/// <param name="wmGUID"></param>
/// <param name="IsInterface">是不是接口的检查</param>
/// <returns></returns>
public string ReflectMehod(ReflectFormat refFormat, string[] tables, ArrayList dsItems, string wmGUID, bool IsInterface)
{
string strtmp = "";
try
{
Type t = GetAssemblyType(refFormat);
if (t == null)
return null;
object obj = Activator.CreateInstance(t);
MethodInfo m;
object[] param;
if (IsInterface)
{
m = t.GetMethod(refFormat.Method, new Type[] { typeof(string[]), typeof(ArrayList), typeof(string), typeof(bool) });
param = new object[4];
param[3] = true;
}
else
{
m = t.GetMethod(refFormat.Method, new Type[] { typeof(string[]), typeof(ArrayList), typeof(string) });
param = new object[3];
}
param[0] = tables;
param[1] = dsItems;
param[2] = wmGUID;
if (m != null)
{
strtmp = (string)m.Invoke(obj, param);
}
return strtmp;
}
catch (Exception ex)
{
pm.SaveLog("BizReflectWork.Reflect", "ReflectMehod", ex.Message);
return "系统发生错误,请与管理员联系!发生在\"BizReflectWork.Reflect\"";
}
}
#endregion
}
} |