Problem with memory usage measurment
<p>I have some C# functions, and I want to measure their memory usage in bytes. I used GC.GetTotalMemory as follows:</p>

<pre><code>long val1 = GC.GetTotalMemory(false);

// my code

long val2 = GC.GetTotalMemory(false);

long result = val2  - val1 ;
</code></pre>

<p>I tried to pass both true and false as argument for GC.GetTotalMemory, but I do not know why I get negative result value, when I subtract val1 from val2 .... Another issue is that GC.GetTotalMemory give different values in each excution, I think it is not accurate </p>

<p>Can anyone know why I get a negative result value ? is it because of the argumenet (true or false), although I tried them both and got negative result value too</p>

<p>Can anyone know why I get different values in each excution of the C# function ?</p>

<p>Please if anyone has a better efficient way to measure memory usage in bytes for C# function in Windows, please tell me and thanks alot </p>
