Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top