Determining Stack Space with Visual Studio

前端 未结 4 710
耶瑟儿~
耶瑟儿~ 2020-11-30 07:05

I\'m programming in C in Visual Studio 2005. I have a multi-threaded program, but that\'s not especially important here.

How can I determine (approximately) how muc

4条回答
  •  情歌与酒
    2020-11-30 07:42

    The stack doesn't work the way you expect it too. The stack is a linear sequence of pages, the last (top) one of which is marked with a page guard bit. When this page is touched, the guard bit is removed, and the page can be used. For further growth, a new guard page is allocated.

    Hence, the answer you want is where the gaurd page is allocated. But the technique you propose would touch the page in question, and as a result it would invalidate the very thing you're trying to measure.

    The non-invasive way to determine if a (stack) page has the guard bit is via VirtualQuery().

提交回复
热议问题