views:

2088

answers:

7

What is the best available tool to monitor the memory usage of my C#/.Net windows service over a long period of time. As far as I know, tools like perfmon can monitor the memory usage over a short period of time, but not graphically over a long period of time. I need trend data over days, not seconds.

To be clear, I want to monitor the memory usage at a fine level of detail over a long time, and have the graph show both the whole time frame and the level of detail. I need a small sampling interval, and a large graph.

A: 

I've used ProcessMonitor if you need something more powerful than perfmon.

SaaS Developer
ProcessMonitor doesn't monitor memory usage; only file access, registry access, etc.
wj32
+3  A: 

Well I used perfmon, exported the results to a csv and used excel for statistics afterwards. That worked pretty well last time I needed to monitor a process

GHad
+5  A: 

Perfmon in my opinion is one of the best tools to do this but make sure you properly configure the sampling interval according to the time you wish to monitor.

For example if you want to monitor a process:

  • for 1 hour : I would use 1 second intervals (this will generate 60*60 samples)
  • for 1 day : I would use 30 second intervals (this will generate 2*60*24 samples)
  • for 1 week : I would use 1 minute intervals (this will generate 60*24*7 samples)

With these sampling intervals Perfmon should have no problem generating a nice graphical output of your counters.

Sacha
Yes, you can change the sampling interval, however, that leaves huge gaps in data. What I'm looking to do is graph the memory usage at a small sampling interval over a long time.
Jon Ediger
It should work with smaller intervals too. Just don't let it running for a whole week with 1 second interval ;-) In Vista/Win2008 I have opened huge BLG files without a problem. You can also export the data to CSV and analyze it in some other statistical tool (like Excel).
Sacha
+1  A: 

Playing around with Computer Management (assuming you're running Windows here) and it seems like you can make it monitor a process over time. Go to computer management -> performance logs and alerts and look at the counter/trace logs. Right click on counter logs and add a new log. Now click add object and select memory. Now click add counters and change the "Performance Object" to Process, and select your process.

ADINSX
+1  A: 

As good as monitoring the memory is by itself, you're probably thinking of memory profiling to identify leaks or stale objects - http://memprofiler.com/ is a good choice here, but there are plenty of others.

If you want to do something very specific, don't be afraid to write your own WMI-based logger running on a timer - you could get this to email you process statistics, warn when it grows too fast or too high, send it as XML for charting, etc.

A: 

If you're familiar with Python, it's pretty easy to write a script for this.

Activestate Python (which is free) exposes the relevant parts of the Win32 API through the win32process module.

You can also check out all win32 related modules or use gotAPI to browse the Python standard libs.

Chopmo
A: 

I would recommend using the .Net Memory Validator tool from software verify. This tool helped me to solve many different issues related to memory management in .Net application I have to work with.

I use more frequently the C++ version but they are quite similar and the fact that you can really see in real-time the type of the objects being allocated will be invaluable to you.

Fabien Hure