Open
Description
Description
The stats provided by MemoryCache might randomly decrease for a short time when a thread dies.
That problem did not occur to me in production but I would like to use a similar pattern in my library, so I would be interested to double check that the pattern is valid.
Reproduction Steps
- A thread dies
- The thread and thread locals get collected
- The WeakReference in MemoryCache._allStats should now point to null
- During that time, the thread local stats is not referenced by the
_allStats
list anymore and is not in the dead threads accumulator either - The Stats finalizer is called and the value of the thread counter is now added to the accumulators.
Expected behavior
The MemoryCache stats should always increase and never decrease.
Actual behavior
The MemoryCache stats might decrease in some rare case.
Activity