15 Jan
2014
15 Jan
'14
1:25 p.m.
2014/1/15 Hartmut Kaiser
Like any C++ probably Boost.Fiber makes many malloc calls per context switch. It adds up.
I don't think that things like a context switch require any memory allocation. All you do is to flush the registers, flip the stack pointer, and load the registers from the new stack.
the context switch itself does not required memory allocation but the function/functor to be executed in the fiber must be stored (type erased) inside the fiber. the current implementation of fiber does allocate internally an object holding the fiber-function. I think it is possible to store the function/functor on top of the stack used by the fiber and thus prevent the need for memory allocation to hold the function/functor.