C # windows app - profiling peak usage and trending

I have a long console application, through millions of iterations. I want to use if memory usage increases linearly as the number of iterations increases .

What would be the best way to do this?

I think I really need to worry about using peak memory during startup? I basically need to find out what maximum number of iterations I can run on this equipment, given the memory on the server.

I am going to set up a batch run of runs and record the results for different interaction sizes, and then graphically display the results to determine the memory usage trend , which can then be extrapolated to any given equipment.

Look for tips on the best way to implement this, which .net methods, classes to use, or should I use external tools. This article http://www.itwriting.com/dotnetmem.php offers me to profile my own application using code to share the shared memory used by the .net environment in other applications on the box.

thanks

+3
source share
5 answers

There are several ways to do this:

Perfmon User Interface

You can use the Performance Montier Control Panel applet (in the Administration section) that comes with Windows to monitor your application. Look at the .Net CLR Memory category and the counters inside it. You can also limit monitoring to just your process. This is probably the easiest since it does not require code changes.

Perfmon API

You can programmatically use performance counters from .Net. For this you need to use the PerformanceCounter class . This is just an API for the same basic information as in the user interface above.

Memory profiler

. , , - ANTI Memory Profiler RedGate .Net Memory Profiler SciTech. , , ( ). CLR Profiler ( ).

Process. , Process.GetCurrentProcess(), , , (MinWorkingSet, MaxWorkingSet, PagedMemorySize64, PeakPagedMemorySize64, PeakVirtualMemorySize64, PeakWorkingSet64, PrivateMemorySize64, VirtualMemorySize64, WorkingSet64). , , , , .


, , , , , Performance Monitor Windows. , , .

+6
+3

, , . PerformanceCounter

Assembly a = Assembly.GetExecutingAssembly();
_PerfCounter = new PerformanceCounter(".NET CLR Memory",
                                      "# Bytes in all Heaps",
                                      a.GetName().Name,
                                      true);

, ,

_PerfCounter.NextValue()

Hope this was helpful

+1
source

Perhaps this tool can do everything you need.

0
source

Better late than never, but in response to a M3ntat comment you need to add β€œ.vshost” to the assembly name parameter if you are working from Visual Studio, for example.

a.GetName().Name + ".vshost"
0
source

Source: https://habr.com/ru/post/1712090/


All Articles