remember to think small. The reason GC is running or that GC can’t keep up with your memory loss is that you’re not handling things well. You don’t have the resources that you do on a PC or on something with more memory, you have to be much more frugal with memory.
There are a couple of common areas people are dealing with when they get into this kind of question, it’s either large string handling, serial ports, or large files. its worth telling us what you’re working on so that we can also suggest other approaches.
I must tell You that I think small, I am using:
-StringBuilder with precised buffer to build String
-I am using streams to read html site from SD card (with small buffers to read it)
-Streams to read and write to sockets
But still using Panda 2 for home automation including WWW server for controlling, SD logger for logging events I sometimes have OutOfMemoryException and I would like to handle it properly, still trying very much to avoid it.
I worked for weeks to make a simple and yet stable http server for the smaller fezs using the Wiz5100 chip and the httplistener class. Those seems at first to be very simple to use, but it is very easy to leak memory from a little ererywhere. It took me weeks to make it stable. Now it can work for weeks without leaking a single memory byte. I encourage you to try my code or at least get inspired by it…