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?