The HttpSessionStateContainer class has ten local variables, so this is approximately 40 bytes, plus 8 bytes for the object's overhead. It has a session identifier string and a collection of items, so it's about 50 bytes when the collection of items is empty. It has a few more links, but I believe that these are links to objects that are common to all objects in the session. So, all that would do about 100 bytes per session object.
If you put an Int32 value type in a collection of session items, it should be boxed. With an overhead of 8 bytes per object, it reaches 12 bytes, but due to limitations in the memory manager, it cannot allocate less than 16 bytes for an object. With four bytes for an object reference, Int32 needs 20 bytes.
If you put a reference type in a collection of elements, you only save the link, so thatβs just four bytes. If it is a literal string, it is already created, so it will not use more memory. The created string will use (8 + 8 + 2 * Length) bytes.
An array of value types will use (Length * sizeof (type)) plus a few bytes. An array of reference types will use (Length * 4) plus a few more bytes for the links, and each object is allocated separately.
A user object uses approximately the sum of the size of its members, plus some additional additions in some cases, as well as 8 bytes of object overhead. An object containing Int32 and Boolean (= 5 bytes) will be complemented by 8 bytes, as well as 8-bit overhead.
So, if you put a string with 20 characters and three integers in the session object that will use approximately (100 + (8 + 8 + 20 * 2) + 3 * (20)) = 216 bytes. (However, a collection of session items will likely allocate a capacity of 16 items, so there are 64 bytes of which you are using 16, so the size will be 264 bytes.)
(All sizes are indicated on a 32-bit system. On a 64-bit system, each reference is 8 bytes instead of 4 bytes.)