Lately we've been experiencing much more issues with our analyzers causing quite some memory usage.
While debugging our own analyzers I was unable to find a culprit (could of course be my own debugging skills ;-) ). During memory profiling, I saw that there's quite some memory which is allocated from the Orleans source generated which is persisted.
Thus, I cloned the repo, gave the predicement to AI and it came with the following conclusion:
- Static unbounded caches in SymbolExtensions.cs — High severity
This is the real leak. Two static ConcurrentDictionary instances in SymbolExtensions.cs accumulate data permanently across all build invocations in a long-running compiler host (e.g., VBCSCompiler):
private static readonly ConcurrentDictionary<ITypeSymbol, TypeSyntax> TypeCache = new(...);
private static readonly ConcurrentDictionary<ISymbol, string> NameCache = new(...);
Because ITypeSymbol/ISymbol keys are associated with their parent Compilation, these caches effectively root entire Compilation object graphs indefinitely. They are never cleared or bounded. In a long-running dev session or CI that builds many projects in the same process, this will grow monotonically.
After doing some manual digging through the repo, I do think AI might be correct here. Can this be verified by the Orleans team and if verified, fixed?
Also, any temporary workaround would be greatly appreciated if this indeed is an issue on Orleans' side.
Lately we've been experiencing much more issues with our analyzers causing quite some memory usage.
While debugging our own analyzers I was unable to find a culprit (could of course be my own debugging skills ;-) ). During memory profiling, I saw that there's quite some memory which is allocated from the Orleans source generated which is persisted.
Thus, I cloned the repo, gave the predicement to AI and it came with the following conclusion:
After doing some manual digging through the repo, I do think AI might be correct here. Can this be verified by the Orleans team and if verified, fixed?
Also, any temporary workaround would be greatly appreciated if this indeed is an issue on Orleans' side.