I started to monitor the memory usage of my application and saw an increased usage over time.
I narrowed it down to mounting the SD-Card.
FileSystem.Mount() increases used memory by around 6kB that get’s collected after Unmount().
Sometimes FileSystem.Mount() increase used memory by an additional 80 / 288 bytes, while the 288 get collect by GC after a while, the 80 bytes stay for ever.
Isn’t your memory usage increasing every iteration?
I think the usage should be constant/ some should get collected after a while,
but not constantly increasing.
If debugger is running, it will change memory used. The better way to test is add this code below, and let the board runs. if the led is on means memory has no change from last read, and of mean has changed.
var current_read = GC.GetTotalMemory(true);
if (current_read != last_read)
{
last_read = current_read;
led1.Write(GpioPinValue.Low);
}
else
{
led1.Write(GpioPinValue.High);
}
Thanks, you were right.
The increase of memory only occurs in debug mode.
After uploading a release version of the program the memory usage didn’t increase anymore.
Even if it’s annoying that I cannot run the program forever in Debug mode and watch what it is doing, I’m relieved that that doesn’t occur when releasing the application.
I use a desktop application that communicates via TCP with the board to see the live log / transfer log files to my pc. So seeing the log is not an issue.
But thanks for the suggestion.