Memory leak when using GrainCancellationToken
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
We use Orleans 3.6.0. Memory leak also is reproducing in 3.6.5
We encountered a memory leak while using `GrainCancellationTokenSource` when single long-running `GrainCancellationToken` was passed at many Grains.
After some research we found that GrainCancellationToken work on `CancellationSourcesExtension`. This extension creates for every Grain where GrainCancellationToken passed to method.
`CancellationSourcesExtension` uses `Interner` which holds `WeakRerences` to all `GrainCancellationToken`. `Interner` has a `System.Threading.Timer` that clears dictionary. This timer references to `Interner` instance by callback method.
`Interner` implements `IDisposable`. His dispose method stops Timer. But `CancellationSourcesExtension` never calls it.
**`CancellationSourcesExtension` is cleaned up by the garbage collector:**

**But `Interner` and its `Timer` not:**


**This is object hierarch:**

P.S. We check source code of this classes at 3.6.5 and do not found any changes.
Contributor guide
Assessment
This issue has not been assessed yet.