How do I get .NET to garbage collect aggressively?

后端 未结 12 784
情书的邮戳
情书的邮戳 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 15:02

    You could implement your own array class which breaks the memory into non-contiguious blocks. Say, have a 64 by 64 array of [64,64] ushort arrays which are allocated and deallocated seperately. Then just map to the right one. Location 66,66 would be at location [2,2] in the array at [1,1].

    Then, you should be able to dodge the Large Object Heap.

提交回复
热议问题