with the code below, the alailable memory keep getting lower and lower, i'm suspecting it's because the variables keep Re-Allocating. Is there a chance to get away with it? Thanks~~~
// Toggling a pin in a loop
long last = DateTime.Now.Ticks;
while (true)
{
long now = DateTime.Now.Ticks;
// Toggle every 500ms
if (now > (last + 10000000))
{
last = now;
// Toggle the pin
loopToggledPin_LED2.Write((GpioPinValue)loopPinState);
loopToggledPin_LED4.Write((GpioPinValue)loopPinState);
// Using the C interop here
loopPinState = AddOneInterop(loopPinState) % 2;
DateTime start = DateTime.Now;
//GC.Collect();
//GC.WaitForPendingFinalizers();
DateTime end = DateTime.Now;
char[] content = ("Free Memory:" + mm.AvailableMemory.ToString() + " GC Time:" + (end - start).TotalMilliseconds.ToString() + " ms").ToCharArray();
//BSP_LCD_Clear(0xFFFF00FF);
for (int i = 0; i < content.Length; i++)
{
BSP_LCD_DisplayChar((ushort)(i * 17), 0, content[i]);
}
}
}
with the code below, the alailable memory keep getting lower and lower, i'm suspecting it's because the variables keep Re-Allocating. Is there a chance to get away with it? Thanks~~~