Argh. I think I'm gonna have to debug my memory leak without the meager methods we already had... I am quite convinced now that the EnableGCMessages method is completely broken in 4.2 when deployed to hardware.
I have now tried 4 .NETMF v4.2 devices and none work (including the Netduino Plus (4.2RC3) and Go (Original Release)). Here is the output from MFDeploy for the Go:
Resolving.
Ready.
RAM left = 109932
RAM left = 106920
RAM left = 104880
RAM left = 102420
RAM left = 99324
RAM left = 95280
[...]
RAM left = 25848
RAM left = 24648
Failed allocation for 5397 blocks, 64764 bytes
Failed allocation for 5397 blocks, 64764 bytes
Uncaught exception
Done.
Waiting for debug commands...
And.. output from the Emulator works fine:
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
GC: 1msec 279984 bytes used, 3914100 bytes available
Type 0F (STRING ): 72 bytes
Type 11 (CLASS ): 396 bytes
Type 12 (VALUETYPE ): 60 bytes
Type 13 (SZARRAY ): 492 bytes
Type 03 (U1 ): 156 bytes
Type 04 (CHAR ): 156 bytes
Type 07 (I4 ): 36 bytes
Type 11 (CLASS ): 144 bytes
Type 15 (FREEBLOCK ): 3914100 bytes
Type 16 (CACHEDBLOCK ): 72 bytes
Type 17 (ASSEMBLY ): 8592 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 1B (DELEGATE_HEAD ): 72 bytes
Type 1D (OBJECT_TO_EVENT ): 24 bytes
Type 1E (BINARY_BLOB_HEAD ): 268080 bytes
Type 1F (THREAD ): 372 bytes
Type 20 (SUBTHREAD ): 48 bytes
Type 21 (STACK_FRAME ): 456 bytes
Type 27 (FINALIZER_HEAD ): 24 bytes
Type 28 (MEMORY_STREAM_HEAD ): 36 bytes
Type 29 (MEMORY_STREAM_DATA ): 396 bytes
Type 31 (IO_PORT ): 36 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 636 bytes
GC: performing heap compaction...
RAM left = 3914100
GC: 1msec 283044 bytes used, 3911040 bytes available
Type 0F (STRING ): 1296 bytes
[...]
-Valkyrie-MT