How to detect if an application is memory bound ? Is there some kind of pattern or a tool ? Mostly for C++ and C# applications... I don't think that there is such a tool in Microsoft Visual Studio.
Well, you can use perfmon
to see what an application is up to. Look in the ".NET CLR Memory" counters - there are loads of available options, such as GC collections (for each generation), percentage of time spent in GC, the size of each generation etc. You can also specify that you only want to see the data for your application.
If that's not detailed enough, you'll want a profiler - there are a number of options here, including the free CLR Profiler from Microsoft.
In most applications this things is actually kind of easy to detect -- i.e. you run out of memory and your app crashes. OTOH, if you what you mean is: is my application thrashing memory by allocating and releasing too much/too often then you have a question that a profiler is much better at answering. Several questions have been asked on stack overflow about which profiler to use.
The various pointers to profiling tools are on target. But, depending on your available tools (and budget ;-), there are some low-tech approaches to get a quick hint:
- Shut down everything else on the box and see if performance improves.
- Run on another box with more memory and see if performance improves.
- Monitor disk activity before, during, and after a run and look for spikes.
Under linux you use hardware-based performance monitoring interface offered by the perfmon kernel patches. They are not in the mainstream kernel and there are two competing approaches at the momemnt (and it will take a lot of time on LKML to decide which one is better), but they both offer access to various hardware counters. Using them you can trace memory bandwidth problems, cache problems, etc. It's fairly low-level stuff, but when performance is concerned these nasty issues matter.
I don't know what tool offers equivalent functionality under windows I think that Intel VTune can do the trick... They claim:
with strong Visual Studio* and .NET integration. Quickly drill down to the source to identify problematic lines of code.
And there is a free evaluation version - so you can give it a try.