locked
ASP NET Cache removed my items without reasons RRS feed

  • Question

  • User635464972 posted

    I'm using HttpRuntime.Cache in my Web Application (framework 3.5 SP1) to save a DataSet. I'm always using the Insert method to update this DataSet in the Cache.  Sometimes after fews minutes, my DataSet is out of the Cache ; it have been removed without an explicit call of the HttpRuntime.Cache.Removed methode. I can follow this accidental deletion with the ReportRemovedCallBack. Until I used the property CacheItemPriority.NotRemobable, it still removed by an unknown phenomenon.


    My code to insert my DataSet :

    HttpRuntime.Cache.Insert(key, consigneDS, null, Cache.NoAbsoluteExpiration, new System.TimeSpan(0, 30, 0), CacheItemPriority.NotRemobable, ReportRemovedCallBack);


    This Web Application is running under IIS 7.0.  Nothing special in the recycling properties of the DefaultPool. The Regular Time Interval of recycling is 1740 minutes. 


    Please I really need some help.

    Wednesday, November 24, 2010 4:48 AM

Answers

  • User-738352979 posted

    please check removed reason from this evenmthandller.ReportRemovedCallBack 

     

    its most probably due to memory leak on server

     

    <cache disableMemoryCollection="true|false" 
           disableExpiration="true|false" 
           privateBytesLimit="number"  // u have increaed this size
           percentagePhysicalMemoryUsedLimit="number" 
           privateBytesPollTime="HH:MM:SS" />
     
    refer this article.
    http://msdn.microsoft.com/en-us/library/ms228248.aspx
    
     
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 24, 2010 5:17 AM

All replies

  • User-738352979 posted

    please check removed reason from this evenmthandller.ReportRemovedCallBack 

     

    its most probably due to memory leak on server

     

    <cache disableMemoryCollection="true|false" 
           disableExpiration="true|false" 
           privateBytesLimit="number"  // u have increaed this size
           percentagePhysicalMemoryUsedLimit="number" 
           privateBytesPollTime="HH:MM:SS" />
     
    refer this article.
    http://msdn.microsoft.com/en-us/library/ms228248.aspx
    
     
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 24, 2010 5:17 AM
  • User712082397 posted

    From MSDN:

    ASP.NET can remove data from the cache for one of these reasons:

    • Because memory on the server is low, a process known as scavenging.

    • Because the item in the cache has expired.

    • Because the item's dependency changes.

    To help you manage cached items, ASP.NET can notify your application when items are removed from the cache.

    Here is the link: http://msdn.microsoft.com/en-us/library/ms178597.aspx

    You can be notified when an item is removed from the application cache. For example, if you have an item that takes considerable amount of processing time to create, you can be notified when it is removed from the cache so that you can replace it immediately. As a result, the next time that the item is requested, the user does not have to wait for it to be processed.

    How to: Notify an Application When an Item Is Removed from the Cache<!---->

    http://msdn.microsoft.com/en-us/library/7kxdx246.aspx

    Wednesday, November 24, 2010 8:02 AM
  • User635464972 posted

    The removed reason is always Removed (whereas I do not make a specific removed of the DataSet). From this evenmthandller.ReportRemovedCallBack, I check the EffectivePercentagePhysicalMemoryLimit property wich always 99 and the EffectvePrivateBytesLimit property wich always 10201119768. I also check the "Cache Total Trims" counter wich is always 0.


    There is 16GB memory on the server and the application uses on average 2.5GB.


    Nothing is declare in the web.config regarding the cache element. 


    Today I'am using the Performance Monitor to check the "Cache API Entries" and sometimes suddenly it decrease. As this moment I check the log file (of the application) and effectively I see all the DataSet that are removed (thanks to evenmthandller.ReportRemovedCallBack).

     <caching>
                <outputCache enableOutputCache="false"
                             enableFragmentCache="true"
                             sendCacheControlHeader="true"
                             omitVaryStar="true" />
                <outputCacheSettings>
                    <outputCacheProfiles>
                        <add enabled="false"
                             name="no" />
                        <add location="Any"
                             duration="60"
                             varyByParam="None"
                             name="short" />
                        <add location="Any"
                             duration="600"
                             varyByParam="None"
                             name="long" />
                    </outputCacheProfiles>
                </outputCacheSettings>
            </cachin


    Wednesday, November 24, 2010 8:52 AM
  • User-1572682418 posted

    I'm having a similar problem. I do not call .Remove() on my cache item anywhere and yet something is removing it (as verified by checking the handler's reason.)

    I am not running out of memory either, and am setting the item to NotRemovable (which i understand actually ignores the memory removal behaviour of ASP.NET - the server should instead continue until and out of memory exception is thrown which I have witnessed before (i.e. I do get Out of Memory exceptions without my item being removed, yet sometimes for no reason the item is just removed on me.)

    Monday, July 11, 2011 1:23 PM