Boost logo

Boost :

Subject: Re: [boost] [context] Why does boost::ctx::minimum_stacksize() on Windows return 65536
From: Cory Nelson (phrosty_at_[hidden])
Date: 2012-09-01 21:41:26

On Sat, Sep 1, 2012 at 7:01 PM, Hartmut Kaiser <hartmut.kaiser_at_[hidden]> wrote:
> Hey all,
> Why is the minimally possible stack size in Boost.Context on Windows set to
> be 64k? This seems to be way too high for applications where only a minimal
> amount of stack is required. I assume, that since Boost.Context allocates
> the stack using VirtualAlloc the minimum possible value should be equal to
> the page size (see
> px).

A thread's minimum stack size is Windows' allocation granularity,
which is not the size of a single page. Currently this is 64KB. See

VirtualAlloc also rounds up allocations to this granularity. If you
request 4KB, you'll actually waste a lot of space and get 64KB.

The allocation granularity can be determined using GetSystemInfo().

Cory Nelson

Boost list run by bdawes at, gregod at, cpdaniel at, john at