The SC20260 has 1M RAM. I created the simple blink program, and used:
var freeRam = GHIElectronics.TinyCLR.Native.Memory.ManagedMemory.FreeBytes;
var usedRam = GHIElectronics.TinyCLR.Native.Memory.ManagedMemory.UsedBytes;
Oh, OK. I am having trouble fitting what I need into < 500 Kb. I have successfully inplemented a large string array into external RAM as well as storing Bitmaps read from files.
During startup I often do GC.Collect() in order to keep processing. I do get this:
Failed allocation for 752 blocks, 12032 bytes
Which is not an exception. Everything appears to function properly though. Is that message an indication of garbage collection ?
Those failed allocations simply say it couldn’t allocate contiguous memory for your new object, which usually leads to GC to re-spread objects in memory and free up contiguous blocks. As you note they’re a soft-fail message not an exception that stops your app, they are just a notice of what is happening
I am able to read bitmap files from SD card and store them directly to external memory. It is stored as a byte array. In order to do a DrawImage I have to convert the byte array to an Image. I am reading the byte array to a MemoryStream and then to Bitmap. This however uses managed memory and there is often not enough available, resulting in out of memory exception. Is there a way to display an Image ( bitmap) directly from external memory ?
Bitmaps are always in unmanaged heap (external memory). You should not use BMP files, use JPEG or GIF, read those in a byte array (secure memroy) and then from there create the “Bitmap”, which is allocated in external memory. Once you have it, discard the byte array as it is no longer needed.
I am assuming you did not call EnableFullHeap of course.