Measuring memory usage in .Net

I am trying to get the program that I am writing (in F #, although I would imagine that the answer here is the same for any CLR language?) In order to report using my own memory (so that I can get an idea of ​​how much I emphasize the machine, compare the sizes different workloads and evaluate the effect of any optimization that I do in the hope of preserving memory).

The good news is that the Process class has a lot of statistics available. http://msdn.microsoft.com/en-us/library/system.diagnostics.process_members.aspx

However, there are so many different values ​​for memory usage. Here are four of the test run:

Peak paged memory size 13,492,224 Peak virtual memory size 138,661,888 Peak working set 14,188,544 Private memory size 13,492,224 

And there are a few others. What is the difference between the two? Which of them are the best answers to the question: "How much memory did the program use for this launch, does it only end now?" And do the same numbers have the same meaning for Mono on Linux or MacOS?

+4
source share
1 answer

It seems like the best figure for a program trying to control its own memory usage is GC.GetTotalMemory.

+1
source

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


All Articles