473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

add tracing/logging to log memory use?

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
2 1193
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Claire | last post by:
My application runs for a while then just stops completely. No stack overflows or any other errors, visual studio doesn't report any problems. I can close the application down ok from the studio...
4
by: John Bowman | last post by:
Hi All, For debugging purposes I'm trying to figure out how to make any and all Exceptions (Exceptions or AppExceptions or custom exceptions) be automatically logged to a text logging file. Is...
0
by: Lenn | last post by:
Can I add my own TextWriterTraceListener listeners in ASP.NET (web service) application. I have the following in web.config file: <system.diagnostics> <trace autoflush="true" indentsize="4">...
0
by: Samy | last post by:
I am trying to use tracing in the loggin and instrumentation application block. I am using forms authentication. For some reason I cannot write to the trace.log. I think I am running into...
1
by: Kejpa | last post by:
Hi, I'd like some custom tracing for my application. Along with the usual stuff like Message and Category I'd like to save what level the trace was at and what time it occurred. I'm not sure...
1
by: ss | last post by:
Hi Can anyone show a sample code where the error handling is done with the logging the errors. What are the best methods of logging the errors in .net perticularly in WEB Application ...
0
by: Scott Holman | last post by:
I have enabled message tracing on the WCF service. I was attempting to see the difference between binding wsHTTP with MTOM message encoding vs wsHTTP with text message encoding. After changing...
4
by: Fresno Bob | last post by:
I was looking at tracing and the way you can write to an axd file. Is there any way of writing this information to a database but only when the page errors.
1
by: RedLars | last post by:
Hi Does the class System.Diagnostics.Trace use a singelton ? I'm able to do this; System.Diagnostics.Trace.WriteLine("test"); However, these give compiler errors; System.Diagnostics.Trace...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.