Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are several ways to do this:</p> <h3>Perfmon UI</h3> <p>You can use the Performance Montior control panel applet (in Administrative Tools) that comes with Windows to monitor your application. Have a look at the .Net CLR Memory category and the counters inside it. You can also limit the monitoring to just your process. This is probably the easiest as it requires no code changes.</p> <h3>Perfmon API</h3> <p>You can programmatically use performance counters from .Net. For this, you'll need to use the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx" rel="noreferrer">PerformanceCounter</a> class. This is just an API to the same underlying information that the above UI presents.</p> <h3>Memory Profiler</h3> <p>You can use a memory profiler to profile you application whilst it is running. The two I have used with success are the <a href="http://www.red-gate.com/products/ants_memory_profiler/index.htm" rel="noreferrer">ANTS Memory Profiler</a> from RedGate and the <a href="http://www.memprofiler.com/" rel="noreferrer">.Net Memory Profiler</a> from SciTech. Again, this requires no code changes, but may cost you money (although there are free trial versions). There is also the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=86ce6052-d7f4-4aeb-9b7a-94635beebdda&amp;displaylang=en" rel="noreferrer">CLR Profiler</a> (a howto can be found <a href="http://msdn.microsoft.com/en-us/library/ms979205.aspx" rel="noreferrer">here</a>).</p> <h3>Roll Your Own</h3> <p>You can get hold of some limited memory information from the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx" rel="noreferrer">Process</a> class. Get hold of the current process using <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getcurrentprocess.aspx" rel="noreferrer">Process.GetCurrentProcess()</a>, and then look at the properties of it, specifically the ones relating to memory (<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.minworkingset.aspx" rel="noreferrer">MinWorkingSet</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.maxworkingset.aspx" rel="noreferrer">MaxWorkingSet</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.pagedmemorysize64.aspx" rel="noreferrer">PagedMemorySize64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.peakpagedmemorysize64.aspx" rel="noreferrer">PeakPagedMemorySize64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.peakvirtualmemorysize64.aspx" rel="noreferrer">PeakVirtualMemorySize64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.peakworkingset64.aspx" rel="noreferrer">PeakWorkingSet64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.privatememorysize64.aspx" rel="noreferrer">PrivateMemorySize64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.virtualmemorysize64.aspx" rel="noreferrer">VirtualMemorySize64</a>, <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.workingset64.aspx" rel="noreferrer">WorkingSet64</a>). This is probably the worst solution as you have to do everything yourself, including data collection and reporting.</p> <hr> <p>If all you are wanting to do is to verify your application doesn't linearly increase its memory usage as your the number of iterations increases, I would recommend monitoring using the Performance Monitor UI in Windows. It will show you what you need with minimal effort on your part.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload