我在共享主机中有一个ASP.Net应用程序,经常回收.我们使用NLog并在global.asax中包含以下代码
void Application_Start(object sender, EventArgs e)
{
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
logger.Debug("\r\n\r\nAPPLICATION STARTING\r\n\r\n");
}
protected void Application_OnEnd(Object sender, EventArgs e)
{
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
logger.Debug("\r\n\r\nAPPLICATION_OnEnd\r\n\r\n");
}
void Application_End(object sender, EventArgs e)
{
HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);
if (runtime == null)
return;
string shutDownMessage = (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
string shutDownStack = (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, …Run Code Online (Sandbox Code Playgroud) 我正在寻找应用程序本身监视其使用的内存量的方法,因此我可以每小时左右将其记录在日志文件中,并密切关注应用程序的使用情况.
它全部托管,因此我们可以对系统进行更改以查看正在发生的事情,因此解决方案必须来自应用程序代码.
我们将来可能会使用内存信息来影响缓存策略.