Main Site Documentation

Error in the output window : GC: 27msec 987912 bytes used, 6351756 bytes available


#1

Hello all,
I need your help I am on a project where I use G120HDR card. I have since the beginning developped a lot of code that works fine , except I have a problem. During the course of my program all goes well until a certain time window where the output it appears that:

GC: 27msec 987912 bytes used, 6351756 bytes available
Type 0F (STRING ): 214284 bytes
Type 11 (CLASS ): 146844 bytes
Type 12 (VALUETYPE ): 26244 bytes
Type 13 (SZARRAY ): 78084 bytes
Type 03 (U1 ): 480 bytes
Type 04 (CHAR ): 480 bytes
Type 06 (U2 ): 108 bytes
Type 07 (I4 ): 468 bytes
Type 0F (STRING ): 144 bytes
Type 11 (CLASS ): 76404 bytes
Type 15 (FREEBLOCK ): 6351756 bytes
Type 16 (CACHEDBLOCK ): 48 bytes
Type 17 (ASSEMBLY ): 31716 bytes
Type 18 (WEAKCLASS ): 96 bytes
Type 19 (REFLECTION ): 180 bytes
Type 1B (DELEGATE_HEAD ): 756 bytes
Type 1D (OBJECT_TO_EVENT ): 336 bytes
Type 1E (BINARY_BLOB_HEAD ): 476784 bytes
Type 1F (THREAD ): 2688 bytes
Type 20 (SUBTHREAD ): 288 bytes
Type 21 (STACK_FRAME ): 5100 bytes
Type 23 (LOCK_HEAD ): 60 bytes
Type 24 (LOCK_OWNER_HEAD ): 24 bytes
Type 27 (FINALIZER_HEAD ): 360 bytes
Type 28 (MEMORY_STREAM_HEAD ): 36 bytes
Type 29 (MEMORY_STREAM_DATA ): 396 bytes
Type 31 (IO_PORT ): 216 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 3300 bytes

From this moment I am unable to use the interrupt button I use to read the SD card

Thank you in advance for your help.


#2

@ MVeloso4 - Something got collected by the GC. Can you, please show your code.


#3

Garbage collector “collects” Button object:

 InterruptPort Button = new InterruptPort(Pin.P2_10, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
            Button.OnInterrupt += Button_OnInterrupt;

Put it as a static variable, like others:

 static ushort Annee;
InterruptPort Button= new InterruptPort(Pin.P2_10, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);


#4

@ Simon from Vilnius - Thank you :slight_smile: , I do not know if it actually solved my problem but it works. Because I always GC: 18msec 929,400 bytes used, 6410268 bytes available but the code continues to function without any problems


#5

@ MVeloso4 - That is exactly why you were not able to use the button. As soon as ProgramStarted was done that object was eligible for GC, because it was declared in a local scope of that method. You moved it to a global scope and the reference is “alive” - not eligible for GC.


#6

In short:
Always Keep an reference to the objects that Needs to stay alive.
.NET Counts the references to any given object.
When GC runs and finds any object with Zero references, the object gets freed.
That, in fact, is the Job of the GC.