views:

55

answers:

3

Does Memory Pressure ever cause Session Information to be evicted in ASP.NET?

If so, will this only happen after all Caches are evicted (even with CachePriority.Highest), or what is the threshold for this to happen?

+1  A: 

Session and Cache are definitely volatile storage mediums. I'm unsure if there is a priority that effects one another, but there are more factors than just memory pressure that you need to account for. For example, Session will be wiped simply by modifying the web.config (which recycles the app pool). This is of course assuming that you are using the default Session storage provider -- you can change to out of process, or SQL Session storage if that may help in your specific scenario.

Matt Hidinger
I'm using out of process ASP.NET Session State Server. However, I wondered if I can ever encounter a scenario where a particular field of a session has been evicted while others are still there.
Alex
+2  A: 

It will not be auto-purged in order to save memory in the same way that Cache is. However, if the worker process runs out of memory, it will be auto-restarted. If you are using InProc session storage, this means that all sessions will be lost.

jsight
Same comment as I made to Matt - I'm using out of process ASP.NET Session State Server. However, I wondered if I can ever encounter a scenario where a particular field of a session has been evicted while others are still there.
Alex
@Alex - No, the ASP.Net Session State Server would never just lose arbitrary values from the Session (due to out of memory or other reasons).
jsight
+2  A: 

The Session object is a single unit. If the session is cut short because of a lack of memory resources, the entire object is removed, not single properties.

If you experience that single values in a Session object disappears, the most likely reason is that you have some code somewhere that removes it.

Guffa