Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak in Microsoft.Extensions.Caching.Memory when handling exceptions #42355

Merged
merged 3 commits into from
Sep 19, 2020

Commits on Sep 16, 2020

  1. Memory Leak in Microsoft.Extensions.Caching.Memory when handling exce…

    …ptions
    
    When an exception is thrown inside MemoryCache.GetOrCreate, we are leaking CacheEntry objects. This is because they are not being Disposed properly, and the async local CacheEntryStack is growing indefinitely.
    
    The fix is to ensure the CacheEntry objects are disposed correctly. In order to do this, I set a flag to indicate whether the CacheEntry.Value has been set. If it hasn't, Disposing the CacheEntry won't add it to the cache.
    
    Fix dotnet#42321
    eerhardt committed Sep 16, 2020
    Configuration menu
    Copy the full SHA
    3ebbb0e View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2020

  1. Respond to PR feedback.

    eerhardt committed Sep 17, 2020
    Configuration menu
    Copy the full SHA
    86b76bf View commit details
    Browse the repository at this point in the history
  2. Fix another memory leak when one cache depends on another cache. The …

    …inner cache's entries will reference the outer cache entries through the ScopeLease object.
    
    Null'ing out the CacheEntry._scope field when it is disposed fixes this issue.
    eerhardt committed Sep 17, 2020
    Configuration menu
    Copy the full SHA
    72d5741 View commit details
    Browse the repository at this point in the history