RE: Memory growth halts with use of Profiler - bug in .NET service



THANK YOU DAVE! More than anything else, your original post and the links
you gave me helped me solve the problem. Where the profilers failed (and I
tried 3 of them including CLRProfiler) sos with ntsd was able to at least
tell me that I had thousands of live Oracleparameter objects that were not
get cleaned up. That pointed me straight to Oracle where I found a known
issue with that and fixed my code to clean the parameter collection before
disposing of my OracleCommand objects.

In addition to that, I found links that helped demystify perfmon and showed
me exactly which counters to use to help track the problem, rather than just
stare at the one number, VA Size, on the task manager.
http://blogs.msdn.com/maoni/archive/2004/06/03/148029.aspx

Warren, this link was on the web page Dave first showed me. If it's not
helpful enough, let me know, I learned some other things while debugging my
code.
http://blogs.msdn.com/mvstanton/archive/2004/04/05/108023.aspx

Jeremy



"Dave Hiniker - MSFT" wrote:

I think this article is a good place to start:
http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/

Hope this helps!

"Warren Sirota" wrote:

Whoops... I posted too soon. Right after I posted, my console app exploded
with hudnreds of megs of memory as well.

So, I could still use a good pointer to a tutorial on debugging memory
issues with the debugger and sos. Thanks.
--
Warren Sirota
www.wsdesigns.com


"Warren Sirota" wrote:

I too have a service (with about 50 threads) that seems to demand unbounded
memory, unless I attach a debugger to it. I have found this discussion
interesting, although I haven't used the Windbg or sos, and I could really
use a pointer to a tutorial, because I'm just a simple application writer,
and I actually need documentation (whcih doesn't appear to be all that
present).

HOWEVER, all that aside, I have to say that when I run my code as an
application instead of as a service, I have no memory problems at all. This
is with *the exact same code* that's in my Main method of the program and in
the OnStart() method of the ServiceBase descendant.

What on earth could be causing this discrepancy?

--
Warren Sirota
www.wsdesigns.com


"JeremyC" wrote:

I was using the .NET Memory Profiler and the ANTS Profiler by Red Gate. They
both did the same thing. I'll try the SOS debugger and also the CLRProfiler,
thanks.

Jeremy

"Dave Hiniker - MSFT" wrote:

Which memory profiler are you using? I agree that is very strange behavior.

Assuming it's managed memory growth (in the GC heap) you should be able to
track it down using the SOS debugger extension. Are you familiar with this
tool? If so, wait until the service has grown to hundreds of MB and then
attach and run !dumpheap -stat to see what type of objects are taking up so
much memory. You can then use !dumpheap -mt to find all objects of that type
in the heap and !gcroot to see what chain of references is keeping each alive.

This is basically the manual version of what CLRProfiler does; the profiler
also does an incredible job of aggregating the results and making it easy to
see where the problem is.

Both of these tools are linked to from
https://blogs.msdn.com/maoni/archive/2004/11/08/254288.aspx

Hope this helps!

"JeremyC" wrote:

Forgot to mention that this is in .NET 1.1 on a Windows XP SP2 platform.

Jeremy

"JeremyC" wrote:

I have .NET Windows Service that is growing and growing getting up to several
hundred MB in VM Size. However, when I attach a memory profiler to the
service, the growth stops and holds a steady state, usually around 40-50 MB.
Requesting the GC to force a Collect does not change the behavior.

Does anyone know why a service would exhibit this behavior. I assumed a
memory leak, but why would it not show up when the profiler is running? I
have searched and searched and not come across this problem anywhere yet.
.



Relevant Pages