[reSIProcate] Huge usage of stack space for debug builds
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).
- Alan