perrich / Hangfire.MemoryStorage

A memory storage for Hangfire.
Apache License 2.0
131 stars 43 forks source link

Fixed a leak of Locks ConcurrentDictionary #21

Closed vtesin closed 5 years ago

vtesin commented 6 years ago

We have long-running WebAPI services, which use HangFire memory storage to dispatch background tasks for our game servers. These tasks are dispatched for every transaction, and after 19-day of execution, we did a dump of the process. It showed that we accumulated 2.4GB in the Locks ConcurrentDictionary. In that time frame, we had 8 million transactions.

Seems that these Locks entries are not removed, and each entry is a BackgroundJob Id based, which is unique, so it will always keep the old entries, whilst accumulating new ones.

perrich commented 5 years ago

Well done. Thanks!