Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 411751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:01:04+00:00 2026-05-12T18:01:04+00:00

I would like to estimate the amount of memory used by each session on

  • 0

I would like to estimate the amount of memory used by each session on my server in my ASP.NET web application. A few key questions:

  • How much memory is allocated just to have each Session instance?
  • Is the memory usage of each variable equal to its given address space (e.g. 32 bits for an Int32)?
  • What about variables with variable address space (e.g. String, Array[]s)?
  • What about custom object instances (e.g. MyCustomObject which holds various other things)?
  • Is anything added for each variable (e.g. address of Int32 variable to tie it to the session instance) adding to overhead-per-variable?

Would appreciate some help in figuring out on how I can exactly predict how much memory each session will consume. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:01:04+00:00Added an answer on May 12, 2026 at 6:01 pm

    The HttpSessionStateContainer class has ten local varaibles, so that is roughly 40 bytes, plus 8 bytes for the object overhead. It has a session id string and an items collection, so that is something like 50 more bytes when the items collection is empty. It has some more references, but I believe those are references to objects shared by all session objects. So, all in all that would make about 100 bytes per session object.

    If you put a value type like Int32 in the items collection of a session, it has to be boxed. With the object overhead of 8 bytes it comes to 12 bytes, but due to limitations in the memory manager it can’t allocate less than 16 bytes for the object. With the four bytes for the reference to the object, an Int32 needs 20 bytes.

    If you put a reference type in the items collection, you only store the reference, so that is just four bytes. If it’s a literal string, it’s already created so it won’t use any more memory. A created string will use (8 + 8 + 2 * Length) bytes.

    An array of value types will use (Length * sizeof(type)) plus a few more bytes. An array of reference types will use (Length * 4) plus a few more bytes for the references, and each object is allocated separately.

    A custom object uses roughly the sum of the size of it’s members, plus some extra padding in some cases, plus the 8 bytes of object overhead. An object containing an Int32 and a Boolean (= 5 bytes) will be padded to 8 bytes, plus the 8 bytes overhead.

    So, if you put a string with 20 characters and three integers in a session object, that will use about (100 + (8 + 8 + 20 *2) + 3 * (20)) = 216 bytes. (However, the session items collection will probably allocate a capacity of 16 items, so that’s 64 bytes of which you are using 16, so the size would be 264 bytes.)

    (All the sizes are on a 32 bit system. On a 64 bit system each reference is 8 bytes instead of 4 bytes.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to find out or at least estimate how much memory does
I use serialization, in order to estimate the amount of memory used for an
I would like to calculate/estimate the amount of time file will take for download.
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to estimate the initial cost that I would need to afford
I would like to write a web interface that resembles Prezi.com in its user
I have an existing business application written in Excel which the client would like
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like a for loop in jquery so that: For every hover_link: show hidden
Would like someone to take a look at my script and tell me where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.