Heap fragmentation when using byte arrays

前端 未结 3 1885
闹比i
闹比i 2021-02-05 10:54

I have a C# 4.0 application (single producer/single consumer) which transfers huge amount of data in chunks. Although there\'s no new memory allocation I run out of memory after

3条回答
  •  孤独总比滥情好
    2021-02-05 11:31

    The GC doesn’t compact the large object heap for you, you can still programmatically compact it. The following code snippet illustrates how this can be achieved.

    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
    GC.Collect();
    

提交回复
热议问题