Profile memory usage in ASP.Net session state

I am trying to figure out the size of a certain session state. On one of our heavy pages (a lot of data in the table), it is getting slower. The problem is resolved by logging out.

I was profiling a page that was looking for JavaScript memory leaks, but I could not find anything. My next attack plan is to look at ViewState and Session State. ViewState will be simple, but session state is a complex task.

Does anyone know of any tricks or tools to help figure out the size of the session state?

EDIT

Session Status - InProc.

+3
source share
2 answers

Measure this:

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;
    }
}

, , ( , ).

+6

ASP.NET, . , .

CodeProject, http ( ).

:

  • , - InProc

    InProc ( ) , , . "" .

  • BinaryFormatter, " " . , ASP.NET " , int, string, bool .."

, , , . , .

+1

Source: https://habr.com/ru/post/1721809/


All Articles