为啥 dotnet 有这么高的虚拟内存占用

2022-06-24

https://www.google.com.hk/search?q=dotnet+virt+so+big&newwindow=1&ei=sY61YuucL5PK2roPiKWUyAU&ved=0ahUKEwirueDE7cX4AhUTpVYBHYgSBVkQ4dUDCA4&uact=5&oq=dotnet+virt+so+big&gs_lcp=Cgdnd3Mtd2l6EAMyBQghEKABMgUIIRCgAToFCAAQgAQ6CwguEIAEEMcBENEDOgsILhCABBDHARCjAjoFCC4QgAQ6DgguEIAEEMcBENEDENQCOggILhCABBDUAjoHCAAQgAQQDDoECAAQHjoECAAQEzoGCAAQHhATOggIABAeEAgQEzoKCAAQHhAIEAoQE0oECEEYAUoECEYYAFDwA1ijZWDzZmgJcAB4AIABuQGIAYgQkgEEMjAuNJgBAKABAcABAQ&sclient=gws-wiz

https://github.com/dotnet/runtime/issues/9199

GC reserves a continuous range of virtual memory for the heap. Actual allocations from that heap then just commit segments of that virtual memory. The GC heap needs to be in a continuous range of virtual memory so that we can quickly find if an address belongs to the heap or not. GC code maintains g_lowest_address and g_highest_address global variables that represent the GC heap range. If we didn't reserve a virtual memory range at once, there would be no guarantee of continuous space where only GC heap can live.

  • GC 保留了堆里面的虚拟内存的一个连续范围。
  • 从堆里面的真实分配里提交虚拟内存的已提交的段。
  • GC 堆需要是虚拟内存的一个连续范围,以便可以快速定位到这个地址是不是属于堆的。
  • GC 代码维护了 g_lowest_address 和 g_highest_address 的全局变量 用来反应 GC 的堆范围 。
  • 一旦如果我们不保留一个虚拟内存的范围,我们将无法保证 GC heap 所在的连续空间存活。
copyright ©2019-2024 shenzhen
粤ICP备20041170号-1