Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

C#
long totalSessionBytes = 0;
BinaryFormatter b = new BinaryFormatter();
MemoryStream m;
foreach(var obj in Session)
{
  m = new MemoryStream();
  b.Serialize(m, obj);
  totalSessionBytes += m.Length;
}
 
Share this answer
 
C#
foreach(var obj in Session)
{
  m = new MemoryStream();
  b.Serialize(m, obj);
  totalSessionBytes += m.Length;
}

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900