How can I determine the memory footprint of a session variable?

假装没事ソ 提交于 2019-12-04 15:00:23

From George Shepherd's ASP.NET FAQ at http://www.syncfusion.com/faq/aspnet/web_c9c.aspx

36.37 Is there any way to know how much memory is being used by session variables in my application?

No

However, you can make an educated guess. The number of bytes in your strings, plus the number of bytes taken up by your other session variables (8 for an int, etc.), times the number of concurrent user sessions.

It follows that your session variables need to be as small as possible. The smaller your session state is, the better the site will scale.

You could change your backing store to SQL Server and look at the size of SessionItemShort or SessionItemLong to get an idea of what the serialized size of the data is. Probably not exact, but should be close.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!