I need to increase the stack size of a boost::thread object. The thread's task is to store a large set 3D points, which is implemented recursively and thus needs quite some memory space on the stack.
int main(int argc, char* argv[]) {
Flashlight *flashlight = new Flashlight();
flashlight->thread_group = new boost::thread_group();
boost::thread::attributes attrs;
attrs.set_stack_size(16*1024*1024);
flashlight->orbslam_thread = new boost::thread(attrs, boost::bind(&Flashlight::orbslam_loop, flashlight));
flashlight->thread_group->add_thread(flashlight->orbslam_thread);
// initializing some more threads ...
flashlight->thread_group->join_all();
return 0;
}
A.) Did I increase the thread's stack size to 16MB correctly in the code listed above?
B.) Is it possible to read the attributes, in particular the current stack size, of a boost::thread object somehow?
Aucun commentaire:
Enregistrer un commentaire