boost::thread attributes setting (call) stack size

瘦欲@ 提交于 2019-12-13 05:05:05

问题


I'm getting crashes in my multi-threaded application which I suspect to be stack overflows (should be a nice site to ask this question) because I'm doing some pretty deep recursion and the crash doesn't happen with smaller orders of the problem. I'm using boost::thread. It offers the possibillity to set the stack size (in advance) via an attribute:

boost::thread::attributes l_ThreadAttributes;
l_ThreadAttributes.set_stack_size(8000000);
boost::thread l_MyThread(l_ThreadAttributes, l_MyFunctor);

I'm not very convinced that this actually works. If I ask the current stack size via the same attribute "get_stack_size()" I get 0. Does anyone have experience with it (I'm working on Windows 7 32-bit, Visual Studio 9 2008, boost_1_54_0)? Furthermore, how would this relate to the value I would put in the linker settings (Properties -> Linker -> System -> Stack Reserve Size -> 8000000 for instance)?

Is there a convenient way to check how much stack I have left at runtime (in the current thread)? The handy stackavail() function that used to be in malloc.h and/or stdlib.h seems to have vanished.

Thanks in advance, Daniel Dekkers

来源:https://stackoverflow.com/questions/17574287/boostthread-attributes-setting-call-stack-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!