views:

34

answers:

1

I have a asp.net web forms app that uses System.Web.Caching.Cache to cache xml data from a number of web services for 2 hours.

  webCacheObj.Remove(dataCacheKey)
  webCacheObj.Insert(dataCacheKey, dataToCache, Nothing, DateTime.Now.AddHours(2), Nothing)

Every 90 minutes a Microsoft Search Server hits a particular (spider) page which calls the code to put the objects into the cache.

The issue i have is that over a period of time, the memory usage of the application grows exponentially. Lets say that in a week, the memory usage of the application pool grows to over 1gb.

I'm using IIS7 and no application pool recycling is currently enabled.

+1  A: 

Your first stop should be here. Is a relatively short man page. Learn it, love it, live it. ;-)

That said, try this:

Cache.Insert(dataCacheKey, dataToCache, Nothing, DateTime.Now.AddHours(2), Cache.NoSlidingExpiration)

p.s. whats up with webCacheObj? Is there a reason you are not calling the static Cache?

Sky Sanders
webCacheObj is a parameter thats passed in to a function in a seperate VB.NET dll class which adds items to the cache. (ByVal webCacheObj As Cache).
GordonB
so it's just a reference to the normal cache object.
GordonB
Adding Cache.NoSlidingExpiration fixed it.... Not sure why it was set to nothing.... Thanks muchly.
GordonB
@GordonB, pleasure. Also, thanks for not complaining when I borked the expiration by using a timespan. fixed it in the post.
Sky Sanders