开发者

C# GC. Do calls to VirtualAlloc and VirtualFree Win32 functions cause page swap?

MSDN says that GC calls the Win32 VirtualAlloc function to reserve segment of memory and calls the Win32 VirtualFree to release segments back to the operati开发者_Python百科ng system.

Does that mean each time a segment allocated/released there is a Page Fault generated (soft or hard - depends on the memory availability).

Is that correct interpretation?


Individual pages within a block allocated by VirtualAlloc are committed via soft page faults. There's no reason for a call to VirtualFree to cause page faults, however, since it's just bookkeeping.

That's not to say that GC allocations always cause page faults: in the absence of a memory leak, the GC will collect garbage, and re-use the part of the heap belonging to that garbabge, before it requests more memory from the OS.


A page fault is a trap to the software raised by the hardware when a program accesses a page that is mapped in the virtual address space, but not loaded in physical memory

So the short answer is NO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜