< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Huge usage of stack space for debug builds


Hi Alan. Good find!

On 9/12/05, Alan Stokes <alan@xxxxxxxxxxxxxxxxx> wrote:
> I'm running on Windows with the Microsoft 7.1 compiler. I'm currently using
> debug builds of everything (because I'm just getting started, and I want
> problem-solving to be as easy as possible when I do something stupid).
>  
>  I notice that even a minimal unit test takes a huge amount of stack space
> (more than the default 1MB). The Dialog constructor alone takes 168kB. This
> all comes from the 8k buffers allocated for every call to GenericLog (in its
> various guises). With optimisations turned off (as they are in debug mode)
> the compiler allocates a separate buffer for each call - I assume in release
> mode it's smart enough to realise the lifetimes are non-overlapping and use
> the same buffer for everything.
>  
>  I was wondering where the default size of 8k comes from? It seems very
> high. After all, most log messages tend to be fairly short, and the system
> will grow the buffer as needed for long messages (with the downside of
> needing to touch the heap). In my own code I do something similar, but set
> the default size to 40 bytes (perhaps a touch low).
>  

It seems reasonable to shrink this down substantially. 40 does seem a
bit on the small side. I'm not sure what makes sense though. Maybe 80?