My application has 10 jagged arrays and 5 lists. Average ones are filled with different data for example double or string types. So I know my application has to consume a lot memory but how can I determine the total amount of memory being used?
I have read to use the GC.GetTotalMemory
so the first thing I did was something like this:
var initialMemory = System.GC.GetTotalMemory(true);
many line of code
...
..
var finalMemory = System.GC.GetTotalMemory(true);
var consumption = finalMemory - initialMemory;
All the code is inside a function which main()
calls his function, but the final result is zero. I saw that finalMemory
is zero also, so first what is going on? the initial memory has a number but final has none.
Is System.GC.GetTotalMemory
is the best option to find out the total of memory that is been used by my application?