How do I get .NET to garbage collect aggressively?

后端 未结 12 785
情书的邮戳
情书的邮戳 2020-12-02 14:33

I have an application that is used in image processing, and I find myself typically allocating arrays in the 4000x4000 ushort size, as well as the occasional float and the l

12条回答
  •  半阙折子戏
    2020-12-02 14:57

    you can use this method:

    public static void FlushMemory()
    {
        Process prs = Process.GetCurrentProcess();
        prs.MinWorkingSet = (IntPtr)(300000);
    }
    

    three way to use this method.

    1 - after dispose managed object such as class ,....

    2 - create timer with such 2000 intervals.

    3 - create thread to call this method.

    i suggest to you use this method in thread or timer.

提交回复
热议问题