High memory usage in .NET Core app

memory-storage
recurring
aspnetcore
Tags: #<Tag:0x00007f49ac08e9c0> #<Tag:0x00007f49ac08e858> #<Tag:0x00007f49ac08e718>

#1

I am trying to use Hangfire to perform various jobs on a daily schedule in an .NET Core 2.1 windows service.

I followed the instructions provided in the docs and everything is working perfectly, except that the memory footprint increases after every job execution. It seems that the jobs are not getting disposed correctly. I tried some very basic jobs (eg. write some text to console) without dependency injection, and this issue still occurs - so I do not think it relates to DI scope or disposal.

Also tried (with no success):
-Using .net core 2.0
-Using in memory storage (instead of SQL server storage)
-Hosting in a Web API instead of windows service
-Disabling the dashboard

Any suggestions would be much appreciated!


#2

I am facing the same issue, I followed steps provided in the documentation to setup. I beleive the the resources arent garbage collected properly. Any improvementson your side?


#3

How are you hosting it? I am hosting as a windows service and was injecting a singleton service into each class which I believe was the issue. Once I changed the singleton to transient, all was fine.

Also note that the memory may not go down immediately after the job ends, but the framework does take care of it eventually. So yes, check your singletons and see if that works!