Reputation: 117
Update I traced down a memory leak issue to the following: there was a memory leak when the program was running as a Windows Service, but not when running as a Console app.
Using ANTS Memory Profiler I saw that the leaked memory was held by the finalizer queue's GC root. So the question become: why were objects stuck in the finalizer queue when the program was run as a Windows Service?
Original question
I am developing a Windows Service in C#. It collects data from network devices periodically. Target framework is 4.6.
I use a TPL ActionBlock to be able to send the request parallely.
My issue: If I run the App as a regular console application, memory usage remains normal. (100 MB) In the debugger it is visible that Garbage Collection hits in regularly.
When the Application run in the session 0, as a Windows Service, the memory usage increases to out of memory exception. (6GB) Attaching Visual Studio Debugger to the Windows Service - it show that GC happens sometimes, but not as often as in regular Console.
Interestingly: this happens on Win10. On one Win7 Virtual machine- this memory problem is present in the service, and runned as a console app too.
Thank you very much for your help!
Upvotes: 1
Views: 1240
Reputation: 117
Using ANTS Memory Profiler I found that the leaked memory was held by the finalizer queue's GC root.
This question lead me to the solution: How can I find the reason for a hung finalizer queue?
I converted my WinForms Application to a Console Applcation, then to a Windows service. I left the [STAThread]
remark before the Main method. This caused the finalizer queue to hang, when the program was run as a Windows Service.
Upvotes: 4