内存压力会导致 ASP.NET 中的会话数据驱逐吗?
内存压力是否会导致 ASP.NET 中的会话信息被逐出?
如果是这样,这只会在所有缓存被逐出之后才会发生(即使使用 CachePriority.Highest),还是发生这种情况的阈值是多少?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它不会像缓存一样被自动清除以节省内存。但是,如果工作进程内存不足,它将自动重新启动。如果您使用 InProc 会话存储,这意味着所有会话都将丢失。
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 对象是一个单独的单元。如果由于缺乏内存资源而缩短会话,则会删除整个对象,而不是单个属性。
如果您遇到 Session 对象中的单个值消失的情况,最可能的原因是您在某处有一些代码将其删除。
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.
Session和Cache绝对是易失性存储介质。我不确定是否存在相互影响的优先级,但是您需要考虑的因素不仅仅是内存压力。例如,只需修改 web.config(回收应用程序池)即可擦除 Session。当然,这是假设您正在使用默认的会话存储提供程序——您可以更改为进程外存储或 SQL 会话存储(如果这可能对您的特定场景有帮助的话)。
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.