Welcome to the Bot Framework SDK for .NET repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using .NET.
This PR addresses a memory leak issue in the ExpressionParser class. Previously, the ExpressionParser class used a ConcurrentDictionary to cache parsed expressions, which could lead to excessive memory usage over time. This PR changes the ExpressionParser class to use an LRUCache instead, which has a maximum capacity and uses a least-recently-used policy to evict entries from the cache when the maximum capacity is reached. This change should help to mitigate the memory leak issue.
Specific Changes
Changed the ExpressionParser class to use an LRUCache instead of a ConcurrentDictionary for caching parsed expressions.
Fixes #6656
Description
This PR addresses a memory leak issue in the
ExpressionParser
class. Previously, theExpressionParser
class used aConcurrentDictionary
to cache parsed expressions, which could lead to excessive memory usage over time. This PR changes theExpressionParser
class to use anLRUCache
instead, which has a maximum capacity and uses a least-recently-used policy to evict entries from the cache when the maximum capacity is reached. This change should help to mitigate the memory leak issue.Specific Changes
ExpressionParser
class to use anLRUCache
instead of aConcurrentDictionary
for caching parsed expressions.Testing
This change was tested using a console application that demonstrates the memory leak issue in
ExpressionParser
: https://github.com/jamesemann/expression-parser-leakBefore:
After: