会话状态ASP.Net的配置内存使用 [英] Profile Memory Usage of Session State ASP.Net
问题描述
我试图找出一个特定的会话状态的大小。在我们的重页面(大量的数据在一个表)之一,它越来越慢得。此问题已通过注销系统的解决。
I'm trying to figure out the size of a particular session state. On one of our heavy pages (lots of data in a table) it gets progressively slower. The issue is resolved by logging out of the system.
我异型找JavaScript的内存泄漏的页面,但我没有发现任何东西。我的攻击的下一个计划是太看的ViewState和会话状态。 ViewState的将是简单的,但会话状态构成了挑战。
I've profiled the page looking for JavaScript memory leaks, but I didn't find anything. My next plan of attack is too look at ViewState and Session State. ViewState will be simple, but Session State poses a challenge.
有谁知道任何技巧或工具,这将有助于找出会话状态的大小?
Does anyone know of any tricks or tools that would help figure out the size of Session State?
修改
会话状态InProc方式。
The session state is InProc.
推荐答案
衡量它:
int totalBytes;
var formatter = new BinaryFormatter();
for(int i = 0; i < Session.Count; i++)
{
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, Session[i]);
stream.Flush();
totalBytes += stream.Length;
}
}
此外,我相信,如果你启用跟踪它会告诉你关于会话的一些细节(不知道这一点,从来没有尝试过我自己)。
Also I believe that if you enable tracing it will show you some details about the session (not sure about this, never tried it myself).
这篇关于会话状态ASP.Net的配置内存使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!