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

How to enable the garbage collector for the external SDRAM? #242

Open weixiongmei opened 7 years ago

weixiongmei commented 7 years ago

Hi, the garbage collector seems like it will kick in when the it's out of memory(it will release the memory by itself), but for the memory section i added by using the following function, the garbage collector seems like not going to kick in when it's out of memory(the board hangs up...), does any one how to enable the garbage collector for the external sdram? (calling GC.Collect() manually can solve the issue, but that's not the way it should works...) Thanks~~~~~

public unsafe void AddExternalMemory(UIntPtr beginning, UIntPtr end) { AddLinearSection(beginning, end, RT.MemoryAttributes.RAM | RT.MemoryAttributes.ExternalMemory | RT.MemoryAttributes.RandomAccessMemory);

        RT.MemorySegment* ptr = (RT.MemorySegment*)beginning;

        while (ptr != null)
        {
            ptr->ZeroFreeMemory();

            ptr = ptr->Next;
        }
    }