【发布时间】:2021-08-06 06:43:04
【问题描述】:
在 Linux 中,我可以使用带有 MAP_GROWSDOWN 标志的 mmap 来为自动增长的堆栈分配内存。引用手册页,
MAP_GROWSDOWN
This flag is used for stacks. It indicates to the kernel
virtual memory system that the mapping should extend
downward in memory. The return address is one page lower
than the memory area that is actually created in the
process's virtual address space. Touching an address in
the "guard" page below the mapping will cause the mapping
to grow by a page. This growth can be repeated until the
mapping grows to within a page of the high end of the next
lower mapping, at which point touching the "guard" page
will result in a SIGSEGV signal.
在 Windows 中有一些等效的技术吗?甚至像询问操作系统这样丑陋的事情也会通知您页面错误,以便您可以在下面分配一个新页面(并通过要求操作系统摆弄页表使其看起来连续)?
【问题讨论】:
标签: c windows memory stack allocation