Skip to content

MemoryCache may under-count its size on net10 when an entry is replaced during an expiration scan #422

Open

Description

@cosmin-staicu

Suspected problem

On net10.0, MemoryCache from Microsoft.Extensions.Caching.Memory may under-count its running size when a sized entry is replaced while an expiration scan runs. An under-count lets a size-limited local tier hold more than SizeLimit before it compacts. Values are never wrong or lost; only the limit is weakened.

What was observed

A probe against the bare framework cache (no library code) replaced a size-3 entry while expiration scans ran:

Runtime Size reported while holding one size-3 entry
net10.0 0 in 193,944 of 200,000 rounds
net8.0 3 every time

Scope

To do

  • Confirm with a standalone repro and measure whether the count drifts permanently or corrects itself.
  • If confirmed, report it upstream to dotnet/runtime with the repro.
  • Decide whether the library needs a workaround until a fix ships.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions