As per my knowledge I know we have 2 types of Session. First is in-proc and another is out-proc. So my question is when user closes the browser, does it free session memory from server too or not?
Asked
Active
Viewed 469 times
1
-
4"If a tree falls in a forest and no one is around to hear it, does it make a sound?" – Igor May 08 '15 at 13:12
1 Answers
6
It does not free the storage (memory, db,..) immediately, but it frees the storage when the session is timed-out.
When the user closes the browser, the server does not know about that. But closing the browser means there is no more request to the server which results in timeout when there is no activity during a period of time.

Khanh TO
- 48,509
- 13
- 99
- 115
-
1Where *memory* could be "RAM memory" or "rows of an SQL db" or "something else" – xanatos May 08 '15 at 13:07
-
@xanatos: makes sense. I've never tried that but I think you're correct. Updated the answer, thanks. – Khanh TO May 08 '15 at 13:11
-
-
@Parveen: No, session state is stored on server. Only the sessionId is stored on the browser (usually as a cookie). There is also support for cookieless, in this case the sessionId is passed in the url. – Khanh TO May 08 '15 at 13:16
-
-
-
@Parveen: the size should be configurable: http://stackoverflow.com/questions/1755348/what-is-the-maximum-size-a-session-variable-can-hold – Khanh TO May 08 '15 at 13:24
-
@Khanh TO does SQLServer session also free memory from DB when session timeout? – Parveen May 08 '15 at 13:36
-
-
@Khanh TO So the conclusion is Session free its memory from(in-memory,State Server and from SQL DB) when no more request are coming. ,right? – Parveen May 08 '15 at 13:38
-
@Henk Holterman: In case we store the session state of out process (e.x in Sql Db). It would make sense to release those rows when the session is timed-out, no? (I think the web server can send a request to clear those rows) – Khanh TO May 08 '15 at 13:41
-
@Parveen: yes, when no more requests are coming during a period of time (timeout) – Khanh TO May 08 '15 at 13:42
-
-
@KhanhTO - Yes it would make sens but I'm not so sure that happens... There is no Session_End event in any other mode than InProc. – H H May 08 '15 at 13:45
-
@Khanh TO can you please tell me 1 more thing in which scenario SQLServer session need to be used? – Parveen May 08 '15 at 13:45
-
@Parveen: in scenarios like you have a farm of servers and you need to share the session states between them. (There may be more, this is one that i could think of right now) – Khanh TO May 08 '15 at 13:50
-
@Henk Holterman: I think this event is only for `additional` cleanup. Asp.net should free its storage (memory for example) before firing this event because freeing a session involves some work like removing all the related objects with a sessionId (in case of in-memory), all of these complicated things should be handled by asp.net automatically. Do you think so? – Khanh TO May 08 '15 at 14:03