Exception thrown: 'System.NotSupportedException' in GHIElectronics.TinyCLR.Drawing.dll

I’m having another issue now. My device reads a number of parameters off of vehicle analytics devices, stores them in external flash memory as ‘records’ then has a view record page where the device can read them off of the external flash, then display past record data. There is a ‘previous’ ‘next’ and ‘exit’ button, with previous and next cycling between more and less recent records. When a user presses one of these buttons, I have the device close its current screen, then reopen the same screen, performing all of its flash reads on a shifted start address, however I am running out of memory between these screens, something that should not be possible if the code is first returning all the memory the screen should take to me, then creating the same screen. Any idea as to why I am running into this error?

Firstly, a quick meta-comment: you should open a new topic for a new issue. That will help you get more relevant attention and will also help people in the future who are looking for the same answer.

As for your actual question, that’s a really hard one to answer without more information or code samples. It’s possible that something hasn’t been fully released yet : Perhaps you are still holding refs to some of the underlying data structures? Review your code for dangling refs. Use breakpoints and/or debug output to make sure that objects are really getting disposed when you expect them to be.

You should also design your code to minimize the use of ‘new’ in repetitive actions. Lots of deallocations and re-allocations will fragment the available memory space and make it harder to allocate new objects even if the total available memory is sufficiently large. Use pre-allocated buffers that you reuse from one screen to the next. This goes for all code, not just UI.

Avoid repainting a whole new screen. Can you just clear and repopulate list elements? Use a ‘minimum flow’ approach when updating UI - only update elements that have actually changed.

For more specific advice, I’d suggest opening a new topic and posting code samples (minimized to the problem and anonymized as much as you need).

3 Likes

Hello, creating a new topic is recommended, please.
In case you wanted a quick answer, look at this: Memory Management (ghielectronics.com)

At bottom of the page, there is Finalizer section.
If you are not sure when/where to put those code, just before switching to a new page or leaving a page to see it does help. If not, your memory is very tied and need to optimize your code as much as you can.

2 Likes