add tracing/logging to log memory use?

  • Thread starter Thread starter hazz
  • Start date Start date
H

hazz

I would like to see where in my application memory is being allocated and
when.
I would like to add code to my Windows Service app so that it 'spits out'
total memory usage at that point as well as a time stamp. I want to add a
literal string to the message indicating exactly where I am at in the
process.

How would I do this? I have been using CLR Profiler and Perfmon. They are
pretty and informative but I need more granular detail that will instrument
my code, not just telling me that System.String or System.Byte[] has
survived the garbage collector.

o.k. i'll admit it, i have a memory leak because I have instantiated a bunch
of objects, i have declarations of various data types at various levels of
scope and now I have to really understand what is going on.

I am using the Enterprise Library if there is anything there that would be
useful.

I thought I say some .NET memory methods/functions that would give me some
statistics but I can't seem to find them.

Thank you for any ideas.

-hazz
 
Trace.WriteLineIf(myTraceSwitch.TraceVerbose, "number of bytes currently
thought to be allocated: " & GC.GetTotalMemory(True).ToString())
 
Are you attempting to answer your own question?

As for how to instrument your application, if you are using the Enterprise
Library, then you have the Instrumentation Application Block. You can
configure it to call WMI in order to inform the PerfMon utility of the
events taking place within your app.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
hazz said:
Trace.WriteLineIf(myTraceSwitch.TraceVerbose, "number of bytes currently
thought to be allocated: " & GC.GetTotalMemory(True).ToString())


hazz said:
I would like to see where in my application memory is being allocated and
when.
I would like to add code to my Windows Service app so that it 'spits out'
total memory usage at that point as well as a time stamp. I want to add a
literal string to the message indicating exactly where I am at in the
process.

How would I do this? I have been using CLR Profiler and Perfmon. They
are pretty and informative but I need more granular detail that will
instrument my code, not just telling me that System.String or
System.Byte[] has survived the garbage collector.

o.k. i'll admit it, i have a memory leak because I have instantiated a
bunch of objects, i have declarations of various data types at various
levels of scope and now I have to really understand what is going on.

I am using the Enterprise Library if there is anything there that would
be useful.

I thought I say some .NET memory methods/functions that would give me
some statistics but I can't seem to find them.

Thank you for any ideas.

-hazz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top