Home Dashboard Directory Help
Search

MemoryCache gets disposed after PollingInterval when used in WebApp in Integrated Pipeline mode by scubadam


Status: 

Closed
 as Deferred Help for as Deferred


16
0
Sign in
to vote
Type: Bug
ID: 764911
Opened: 9/27/2012 3:22:40 AM
Access Restriction: Public
1
Workaround(s)
view
11
User(s) can reproduce this bug

Description

When using either the MemoryCache.Default or my own MemoryCache after the PollingInterval (default of 2 minutes) the cache is in the disposed state (_disposed=1 ) on examination in the debugger. Setting the PollingInterval longer or shorter means the cache works for more or less time. In its disposed state the cache basically functions as if it is constantly empty hence no cache.
Before the PollingInterval however the cache works as expected.

This only seems to manifest itself when using Integrated Managed Pipeline Mode in IIS7. When on IIS6 or running in Classic mode under IIS7 I did not experience this issue and I found this due to a degradation in performance going from old server to a new server.

A number of people seem to have noticed this but I don't see a bug for this issue here.
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1233ffb3-6480-431b-94ca-1190f96cf5f6
Details
Sign in to post a comment.
Posted by johval on 8/16/2013 at 12:21 AM
We are also experiencing this problem. Apparently the quick fix is still not available?
Posted by Stimo on 5/28/2013 at 4:15 AM
Scott, thanks for the update. Any news on the quick fix (#578315)? It's still not available for download.

Thanks,
Stimo
Posted by Scott Hanselman on 3/30/2013 at 12:10 AM
So, here's some news. We looked into this and YES, this is a bug in .NET 4.

The good news is that it was fixed in .NET 4.5, so if you can, update your installation to .NET 4.5 and you're solid.

The other good news it that this fix has been back-ported to .NET 4 and will be available as a QFE (Quick Fix...a one off fix you'll apply) #578315. It was backported/fixed and it should be out ASAP. I'll try to get an exact date, but it's soon.

The other other good news is that there's a workaround for this on .NET 4 before the QFE. The workaround is weird, but it could unblock you.
using (ExecutionContext.SuppressFlow()) {
// Create memory cache instance under disabled execution context flow            
return new YourCacheThing.GeneralMemoryCache(…);
}

Hope this helps.
Posted by fuzzyGURU on 3/13/2013 at 8:47 AM
Adding this to the web.config helps to some degree:

<configuration>
<system.runtime.caching>
    <memoryCache>
     <namedCaches>
         <add name="Default"
             cacheMemoryLimitMegabytes="0"
             physicalMemoryLimitPercentage="0"
             pollingInterval="00:02:00" />
     </namedCaches>
    </memoryCache>
</system.runtime.caching>
</configuration>


However, I have noticed that once the pollingInterval has been hit, the ObjectCache becomes useless. This means that I need to set the pollingInterval to a high value, and then ensure that the AppPool recycles before that so it is always reset first before it dies.
Posted by scubadam on 2/20/2013 at 7:50 AM
Is there any update on this? Is there a permission needed by the pool Identity service account that would allow this to work. Alternatively does .Net 4.5 fix this?
Anything?
Posted by bcathey on 11/12/2012 at 1:55 PM
Same here. on IIS7; Integrated Mode; .Net 4.0.30319.
I thought ASP.Net MVC on IIS7 would be a well-tested scenario for this since it supposedly replaces ASP.Net caching. I started to worry when I couldn't Get() from cache across processes in tests. I will probably look at NCache (http://www.alachisoft.com/ncache/) if this isn't resolved in the very short term.
Posted by CC_VICTOR_VIANA on 11/8/2012 at 4:30 AM
Good morning!
I'm having the same problem only in IIS 8,
I assign an object in the cache and then immediately try to retrieve and recover when I see what is null.

Has anyone got a solution to this problem Cache?
Posted by scubadam on 10/23/2012 at 2:01 AM
Ok I created a simple reproducer (I attached the file but cannot see it...)
On doing this I noticed some more requirements to see this issue. You have to be using an AppPool running as a specific username, in this case my own user but equally a service account on servers. And the site has to be run with Windows Auth required.

In this instance a simple reproducer shows the exact behavior myself and others have seen.
Hopefully this should be enough for you to advise what is going wrong and what I should do.
Posted by scubadam on 10/23/2012 at 1:07 AM
I also found that this wasn't an issue on a WCF webservice and the Website where this is an issue is a Webforms aspx website. I haven't tried it on an MVC project.
Posted by scubadam on 10/8/2012 at 6:54 AM
I found the specific Framework version according to the App pool in IIS 4.0.30319
Posted by scubadam on 10/4/2012 at 1:26 AM
.Net v4 as specified in the details is the one used by the application pool and the target version of the web app. Is there a more specific version number you are after and how do I find it.
Posted by Microsoft on 10/3/2012 at 3:54 PM
Can you please indicate what version of ASP.NET you are experiencing the issue on?
Posted by Microsoft on 9/27/2012 at 11:33 PM
Thanks for your feedback. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 9/27/2012 at 3:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Scott Hanselman on 3/30/2013 at 12:11 AM
So, here's some news. We looked into this and YES, this is a bug in .NET 4.

The good news is that it was fixed in .NET 4.5, so if you can, update your installation to .NET 4.5 and you're solid.

The other good news it that this fix has been back-ported to .NET 4 and will be available as a QFE (Quick Fix...a one off fix you'll apply) #578315. It was backported/fixed and it should be out ASAP. I'll try to get an exact date, but it's soon.

The other other good news is that there's a workaround for this on .NET 4 before the QFE. The workaround is weird, but it could unblock you.

using (ExecutionContext.SuppressFlow()) {
// Create memory cache instance under disabled execution context flow            
return new YourCacheThing.GeneralMemoryCache(…);
}

Hope this helps.
File Name Submitted By Submitted On File Size  
TestMemoryCache.zip 10/23/2012 2.39 MB
TestMemoryCache.zip 10/23/2012 2.39 MB