Memory cache is not getting released after expiration

243 Views Asked by At

I used System.Runtime.Caching.ObjectCache to store images in video. After expiration interval, cache is getting expired. But memory didn’t get released. Same behavior was observed in .Net framework 4.6.1 and .Net 5.0. Please find the code snippet below

int expiration_interval_minutes = 5;
ObjectCache cache = MemoryCache.Default;
CacheItemPolicy policy = new CacheItemPolicy();
policy.SlidingExpiration = TimeSpan.FromMinutes(expiration_interval_minutes);
string cacheKey = "some_key";
cache.Set(cacheKey, file_byte_array, policy);

Can anyone guide us to resolve this issue?

0

There are 0 best solutions below