开发者

how to know how many memory resources I'm using with sessionState variables

开发者 https://www.devze.com 2023-02-08 09:01 出处:网络
It\'s possible to know how many memory resources I\'m using with SessionState variables in an Asp.Net site? I don\'t want to make changes to the application to resolve it. Will be great if I can know

It's possible to know how many memory resources I'm using with SessionState variables in an Asp.Net site? I don't want to make changes to the application to resolve it. Will be great if I can know this using some tool or the IIS.

I'm planing to move the sessionState from InProc to Sql, but开发者_高级运维 I need to know first how big is the problem I have.

Thanks.


According to this answer here, there is no way to know how much memory is being used by session. But you can make a guess (see also that question I linked and the answer from Mark Schupp here):

For each session variable:

2* the number of chars in the name
+ 8 bytes overhead
+ Data size

Remember that strings are stored internally as unicode (2 bytes/char).


You can write your own, and check amount of data in session state. By it is hard way... Details here.


You can try it:

BinaryFormatter bf = new BinaryFormatter();
MemoryStream m = new MemoryStream();
foreach(var obj in Session) {
  bf.Serialize(m, obj);
}

long bytes = m.Length; // real size
0

精彩评论

暂无评论...
验证码 换一张
取 消