locked
What is the maximum size a session variable can hold ? RRS feed

  • Question

  • User-1313403535 posted

    What is the maximum size a session variable can hold ? I am trying to store object in session variable, if object size is under 80 KB, then working fine and if the size is greater than 80 KB then on retereival I am getting exception.

    How can I increase the session variable size?

    This behaviour is on my production server, on the developement machine I can store big objects like above 500 KB etc..

    Thanks

    Wednesday, November 18, 2009 6:36 AM

All replies

  • User-925286913 posted

    I think size is not the problem. There isn't any restriction on size a session variable can store.

    Refer:

    http://forums.asp.net/t/1143942.aspx

    Post your code to better understand problem.

    Wednesday, November 18, 2009 8:37 AM
  • User-1313403535 posted

    @chintanpshah; Plz check this URL and here I have post the code and you will find more details here.

    http://stackoverflow.com/questions/1755348/what-is-the-maximum-size-a-session-variable-can-hold

    Thanks

    Wednesday, November 18, 2009 8:45 AM
  • User1164098974 posted

    There is no hard limit on the size of a session variable.  Since it is stored on the server in memory, there would be a limitation there, but it would vary depending on your hardware.


    Wednesday, November 18, 2009 8:49 AM
  • User533502567 posted

    What is the maximum size a session variable can hold ?
     

    I belive there is no such thing for individual session variable size. It all depends on total number of sessions and webserver's memory.

    if object size is under 80 KB, then working fine and if the size is greater than 80 KB then on retereival I am getting exception.

    Session is not recommended for storing large objects. Recommended usage: 

    Use when you are storing short-lived information that is specific to an individual session and security is an issue. Do not store large quantities of information in session state. Be aware that a session-state object will be created and maintained for the lifetime of every session in your application. In applications hosting many users, this can occupy significant server resources and affect scalability.

    Consider using other state management methods..

    http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx

    Wednesday, November 18, 2009 10:01 AM
  • User1123702521 posted

    What is the maximum size a session variable can hold ? I am trying to store object in session variable, if object size is under 80 KB, then working fine and if the size is greater than 80 KB then on retereival I am getting exception.

     

    Hi! Please note that in SessionState collection, items are stored as objects and they will consume as much space as an object type is allowed and the theoretical limit for the maximum size of an object is 2GB. Please check this. But practically it will depend on the available memory resources that your server has got and are available to you. Also maintaining heavy objects in memory is not recommend because its a precious server resource so I would recommend to store these objects in database and make available to your client upon request. ( A trick could be to only store the id of the record in Session)

     

    Thanks.

    Wednesday, November 18, 2009 12:54 PM
  • User-556463544 posted

    There is no limitation like that.

    As it seems you are dealing with file upload, try changin the MaxRequestLength in web.config file.


    Is that fileupload1 is a control? Then its not advisable to keep a control inside session !!!

    Friday, November 20, 2009 5:13 PM
  • User650311923 posted

    Hi,

    i am using session storage in browser side, when i am setting collection of stringifyed objects into the sessionStorage("ListObject") it shows script error like below,

    Uncaught DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'ListObject' exceeded the quota"

    any solution to solve this problem with out clearing the session storage value?

    Tuesday, June 20, 2017 9:38 AM