Making ones own memory profiler lite in c#

  • Thread starter Thread starter Sam Samson
  • Start date Start date
S

Sam Samson

Can any-one recommend some good sites detailing how to code a simple memory
profiler?
How do they "look under the hood"?

I built an uber simple service that tracks the process' memory but I need
to "get inside" and look a bit deeper and I don't have a clue where to start
... a commercial memory profiler is not an option due the nature of the environment
the application is deployed in ..

My app runs fine for weeks (in 8 locations) but every now and again it goes
BOOOOOM
Operator feedback is non-existent so how they do it eludes me and it never
ever misbehaves in the test environment.

So my plan is to automatically detect when the app is starting to creep up
and start looking inside to see what exactly is going on. (its a plan of
sorts)

If I dont go insane before then ...
 
Hi Sam,

have you checked out the .Net Profiler API? there are loads of great
articles on the MSDN website:

http://msdn.microsoft.com/msdnmag/issues/03/01/NETProfilerAPI/
http://msdn.microsoft.com/msdnmag/issues/05/01/CLRProfiler/
http://msdn.microsoft.com/msdnmag/issues/06/04/NETProfiling/default.aspx#Resources

As for your application are you using any logging and tracing? surely you
could increase the logging when you believe the application is behaving in a
strange manner.

Why can't you use a memory profiler in product if you can't recreate the
problem in development?

HTH

Ollie Riches
 
Hello Ollie,


Nope hadn't but now I have a starting place so shall be real soon. Thanks

As for your application are you using any logging and tracing? surely
you could increase the logging when you believe the application is
behaving in a strange manner.

I log all caught and uncaught exceptions .. but this has revealed nothing
.... I peppered the application with 'trace' points that gives me an idea
what it was doing at any given time. but I cant collect the right information
here ..
Why can't you use a memory profiler in product if you can't recreate
the problem in development?

I havent found any in-product ones yet that I could A) understand ... b)
Afford C) run on a machine in the production environment.(locked down PC's)

Thats not to say there isn't a product that fits the bill ... I just havent
found it yet.
 
Hi Sam,

I suggest you use the System.Diagnostics.Trace class as this will output
trace information in realtime, it can be viewed using a tool called Debug
Viewer

http://www.microsoft.com/technet/sysinternals/Miscellaneous/DebugView.mspx

and also process monitor & process explorer, which gives more information
than task manager

http://www.microsoft.com/technet/sysinternals/systeminformationutilities.mspx?wt.svl=featured

Also if you want to check for a memory leaks in your application you should
check Rico Mariani's blog and especially the entry about examianing
application memory.

http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx

If you are looking for a memoery profiler check out the .Net profiler
available from MSDN, it's free

1.1

http://www.microsoft.com/downloads/...52-d7f4-4aeb-9b7a-94635beebdda&displaylang=en

2.0

http://www.microsoft.com/downloads/...1c-3870-43be-8926-862b40aa0cd0&displaylang=en

Another great profiler is Ants .Net Profiler, this will give you a 2 week
eval period.

http://www.red-gate.com/products/ants_profiler/

HTH

Ollie Riches
 
Back
Top