By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,667 Members | 1,348 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,667 IT Pros & Developers. It's quick & easy.

add tracing/logging to log memory use?

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Trace.WriteLineIf(myTraceSwitch.TraceVerbose, "number of bytes currently
thought to be allocated: " & GC.GetTotalMemory(True).ToString())
"hazz" <hazz@sonic_net> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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" <hazz@sonic_net> wrote in message
news:ej**************@TK2MSFTNGP15.phx.gbl...
Trace.WriteLineIf(myTraceSwitch.TraceVerbose, "number of bytes currently
thought to be allocated: " & GC.GetTotalMemory(True).ToString())
"hazz" <hazz@sonic_net> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
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


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.