I am doing a service app which will run continuously for that i need to take care of memory usage in my code.
I am using Stopwatch class to calculate the code performance,
for e.g) Return value vs Out parameter - i just calculate this using for () loop with higher iteration count and found that Out parameter took less time than Returning value from method.
int Iterations = 10000000;
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < Iterations; i++)
{
BigStruct bs = ReturnValue();
total += bs.dec1;
}
sw.Stop();
Console.WriteLine("Using return value: {0}",
sw.ElapsedMilliseconds);
sw = Stopwatch.StartNew();
for (int i = 0; i < Iterations; i++)
{
BigStruct bs;
OutParameter(out bs);
total += bs.dec1;
}
`Console.WriteLin`e("Using out parameter: {0}",sw.ElapsedMilliseconds);
Similarly, I want to calculate memory usage of my code how much memory is taking while passing bitmaps array to another method as value type argument. so i can find out the high memory usage and change the my code accordingly.
So this will highly help me to find out the best way instead of googling for all..
Thanks.