NETMF / llilum

Development Platform for MSIL and UWP apps targeting Micro Controllers. Part of the .NET Micro Framework family.
Other
159 stars 52 forks source link

Why memory keep reducing? #243

Open weixiongmei opened 7 years ago

weixiongmei commented 7 years ago

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]);
                }
            }
        }
snikeguo commented 7 years ago

@weixiongmei 这个项目估计完了....,兄弟,有很多BUG是正常的