本文介绍了如何查找会话占用的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i有临时表包含n个记录,该表存储在会话中我现在想知道会话占用了多少内存。
感谢All
Hi All ,
i have temporary table that contain n numbers of record ,that table is stored in session now i want to know how much memory is occupied by session .
Thanks To All
推荐答案
long totalSessionBytes = 0;
BinaryFormatter b = new BinaryFormatter();
MemoryStream m;
foreach(var obj in Session)
{
m = new MemoryStream();
b.Serialize(m, obj);
totalSessionBytes += m.Length;
}
foreach(var obj in Session)
{
m = new MemoryStream();
b.Serialize(m, obj);
totalSessionBytes += m.Length;
}
在foreach循环中你写了会话。什么是这个会话名称或什么?
我在那里写了我的会话名称,但是控制不在循环内部。
In foreach loop you wrote session. What is this session name or what?
I write my session name there, but control is not going inside of loop.
这篇关于如何查找会话占用的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!