.net - How to programatically monitor GC activity in a C# application? -


this question has answer here:

i have c# console application in i'd programatically (without aid of visual studio) monitor gc activity. example, if have code:

public static void main() {     (int = 0; < 100000; i++) allocatebytearray(); }  private static void allocatebytearray() {     new byte[1000]; } 

is there way use gc class monitor how many times garbage collection occurs while loop running? tried this:

console.writeline("before:"); console.writeline(gc.gettotalmemory(false));  // work...  console.writeline("after:"); console.writeline(gc.gettotalmemory(false));  console.writeline("after collection:"); console.writeline(gc.gettotalmemory(true)); 

but realized measurements weren't telling me anything, since gc occurred while doing work. i'm not familiar gc apis in .net, there way measure these kinds of statistics programatically? thanks.

i can't know remotely enough directly helpful, there couple things pulled when went hunting answer in curiosity. these things not irrelevant in light of specific bit "without aid of visual studio"

there's thread here on this. monitoring garbage collector in c#

and msdn have documentation regard it. https://msdn.microsoft.com/en-us/library/ee851764(v=vs.110).aspx

for me, garbage collector pretty mystical thing, still.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -