Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Why memory keep reducing? #243

@weixiongmei

Description

@weixiongmei

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]);
                }
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions