NimaAra / Easy.MessageHub

No need for .NET Events! A thread-safe, high performance & easy to use cross platform implementation of the Event Aggregator Pattern.
MIT License
258 stars 41 forks source link

ThreadLocal(trackAllValues: true) keeps the Values collection growing whenever a new thread is created #27

Closed BalintPogatsa closed 1 month ago

BalintPogatsa commented 1 month ago

If you have a MessageHub for the entire lifetime of your application and threads are being created and terminated, each thread with a Subscription / Unsubscription or Publish will make the ThreadLocal.Values collection to grow.

I've found out the issue with a .NET 4.7 WPF application and Easy.MessageHub version 5.0.0.0

Also ThreadLocal.Values getter started to take longer and longer. After few days of running, I had 6632 Instances of "Easy.MessageHub.Subscription[]" and calling Unsubscribe took more than a minute.

NimaAra commented 1 month ago

Thank you for reporting this. This should now be fixed as of v5.1.0. Can you please give it a try and let me know if this is still an issue.