FEZ Raptor - How long does GC take?

Hi all,

I know it is not possible to say it exactly because it depends on application but bellow there is an output from my application.
There is written 264msec. Does it take really so much time on a such a powerful controller which is used on G400 module?
From long term debug output (cca. 3 hours) it is possible to see that GC is executed every cca. 5 min. and what is interesting is that this time is always exactly the same - 264msec.

And second question is if this time is the same also for “release application” or it is valid only for “debug application” connected to VS(and is significantly shorted for release application)?


GC: 264msec 437280 bytes used, 66668484 bytes available
Type 0F (STRING ): 9504 bytes
Type 11 (CLASS ): 31260 bytes
Type 12 (VALUETYPE ): 3144 bytes
Type 13 (SZARRAY ): 14784 bytes
Type 03 (U1 ): 2628 bytes
Type 04 (CHAR ): 1056 bytes
Type 07 (I4 ): 1716 bytes
Type 0F (STRING ): 4968 bytes
Type 11 (CLASS ): 4416 bytes
Type 15 (FREEBLOCK ): 66668484 bytes
Type 17 (ASSEMBLY ): 36324 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 168 bytes
Type 1B (DELEGATE_HEAD ): 936 bytes
Type 1D (OBJECT_TO_EVENT ): 576 bytes
Type 1E (BINARY_BLOB_HEAD ): 325704 bytes
Type 1F (THREAD ): 3072 bytes
Type 20 (SUBTHREAD ): 384 bytes
Type 21 (STACK_FRAME ): 5928 bytes
Type 22 (TIMER_HEAD ): 288 bytes
Type 26 (WAIT_FOR_OBJECT_HEAD): 96 bytes
Type 27 (FINALIZER_HEAD ): 360 bytes
Type 31 (IO_PORT ): 324 bytes
Type 33 (I2C_XACTION ): 48 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 4260 bytes


Thanks for reply.

Not possible to say.

GC is garbage compaction - so the way to improve the GC’s performance is not to dispose objects unnecessarily - for example create buffers for objects you reuse instead of destroying and recreating.

The amount of work GC has to do is directly related to how long it takes - in your case, it seems like needed compaction is pretty repeatable

Yes, it depends…
for example in a application I’m just testing I call GC at a certain place in the code to pervent GC from interrupting at another place and get this Output (Raptor):

GC: 1msec 417648 bytes used, 66688116 bytes available
Type 0F (STRING ): 1356 bytes
Type 11 (CLASS ): 14568 bytes
Type 12 (VALUETYPE ): 1200 bytes
Type 13 (SZARRAY ): 19176 bytes
Type 03 (U1 ): 14028 bytes
Type 04 (CHAR ): 1572 bytes
Type 07 (I4 ): 1404 bytes
Type 11 (CLASS ): 2172 bytes
Type 15 (FREEBLOCK ): 66688116 bytes
Type 17 (ASSEMBLY ): 35580 bytes
Type 18 (WEAKCLASS ): 96 bytes
Type 19 (REFLECTION ): 192 bytes
Type 1B (DELEGATE_HEAD ): 720 bytes
Type 1D (OBJECT_TO_EVENT ): 360 bytes
Type 1E (BINARY_BLOB_HEAD ): 335184 bytes
Type 1F (THREAD ): 1152 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 3252 bytes
Type 26 (WAIT_FOR_OBJECT_HEAD): 48 bytes
Type 27 (FINALIZER_HEAD ): 264 bytes
Type 31 (IO_PORT ): 324 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 4008 bytes
GC: performing heap compaction…
Got free memory: 66688116 with time for Garbage Collection of 7 ms

and I estimate the time with this code


 TimeSpan StartTicks = Microsoft.SPOT.Hardware.Utility.GetMachineTime();  //Only to calculate time needed for GC

mem = Debug.GC(true);
TimeSpan Endticks = Microsoft.SPOT.Hardware.Utility.GetMachineTime();
long Duration = Endticks.Subtract(StartTicks).Ticks;

Debug.Print("Got free memory: " + mem.ToString() + " with time for Garbage Collection of " + (Duration / TimeSpan.TicksPerMillisecond).ToString() + " ms");


The difference of 6 ms seems to be due to the overhead to calculate the time

1 Like