views:

270

answers:

2

I do some C# fat application on Citrix/Terminal Server.

How to measure actual memory usage per-session? What can I do to reduce the memory usage in total?

We still working on .NET 1.1. Does it have a difference if we upgrade our .NET runtime?

A: 

Here is an article from MSDN on measuring application performance. It includes doing measurements on memory usage.

I don't think upgrading the .NET Runtime will have a significant effect on the application as it is, you will probably be better off optimising your application in other ways. Try to dispose of resources when you don't need them.

Rune Grimstad
+1  A: 

Its very difficult to get metrics on actual memory usage in .NET. About the closest approximation you can get is on a per-object basis by calling Marshal.SizeOf(). My understanding of that method is that it is essentially measuring the size of a serialized version of the object, and the in-memory footprint may be close to that, its not exact. But its a good estimate.

You may also want to investigate the SMS API's under .NET. They provide ways to query various memory statistics from the Operating System about your process (or other processes). Its the same library that is used by "perfmon". You may be able to use that to inspect your process programatically.

Also, you'll want to invest in a good profiling tool for .NET. I've evaluated ANTS and dotTrace. They are both very good. I preferred dotTrace for its simplicity. Most profilers have very non-intuitive interfaces. That's something I've just come to expect. dotTrace is actually quite good, by those standards. ANTS I think is probably more advanced (not sure, just my opinion from the brief eval I did on both of them).

dviljoen