Hello,
I think I've got a memory leak in a C#/.NET service I created. I hope
someone can help point me in the right direction.
The service runs fine and does what it is supposed to do. But when I pound
on it, over time, the task manager shows the program 'Services.Exe' (not my
service program) takes up more and more memory.
For example:
After a reboot and before starting my service, Services.Exe shows up as
using 3,384K of memory.
After I start my service, but before I use it, Services.Exe shows up as
using the same amount of memory.
Then I start pounding on it, invoking the service again and again. After
10,000 calls to the service, Services.Exe has gone from using 3,384K of
memory to using 134,632K of memory. I know this is a vague question, but
what could my service be doing that would cause such an increase in memory
use in the Windows program Services.Exe? The memory usage does not decline
when I stop my service nor when I force a garbage collection.
My service creates threads, uses TcpListener, and creates sockets for each
connection so there is ample room for me screwing up. I just don't know
where to start looking. I can't tell what Services.Exe is using the memory
for.
I'm still learning .NET/C# so I apologize for my lack of understanding. If
anyone has any suggestions on where I might start looking, I would appreciate
it greatly.
Thanks!

Signature
Brian
Michael Nemtsev - 09 Feb 2007 11:45 GMT
Hello brian,
Use profiling tools to understand what's goint on
And read this article http://msdn.microsoft.com/msdnmag/issues/07/01/ManagedLeaks/default.aspx?loc=en
---
WBR, Michael Nemtsev [C# MVP]. Blog: http://spaces.live.com/laflour
team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
b> I think I've got a memory leak in a C#/.NET service I created. I
b> hope someone can help point me in the right direction.
b>
b> The service runs fine and does what it is supposed to do. But when I
b> pound on it, over time, the task manager shows the program
b> 'Services.Exe' (not my service program) takes up more and more
b> memory.
b>
b> For example:
b>
b> After a reboot and before starting my service, Services.Exe shows up
b> as using 3,384K of memory.
b>
b> After I start my service, but before I use it, Services.Exe shows up
b> as using the same amount of memory.
b>
b> Then I start pounding on it, invoking the service again and again.
b> After 10,000 calls to the service, Services.Exe has gone from using
b> 3,384K of memory to using 134,632K of memory. I know this is a vague
b> question, but what could my service be doing that would cause such an
b> increase in memory use in the Windows program Services.Exe? The
b> memory usage does not decline when I stop my service nor when I force
b> a garbage collection.
b>
b> My service creates threads, uses TcpListener, and creates sockets for
b> each connection so there is ample room for me screwing up. I just
b> don't know where to start looking. I can't tell what Services.Exe
b> is using the memory for.
b>
b> I'm still learning .NET/C# so I apologize for my lack of
b> understanding. If anyone has any suggestions on where I might start
b> looking, I would appreciate it greatly.
b>
b> Thanks!
b>
Brian - 09 Feb 2007 15:46 GMT
Thank you Michael.

Signature
Brian
> Hello brian,
>
[quoted text clipped - 43 lines]
> b> Thanks!
> b>