Multi-thread program: Unhandled exception: Cannot allocate new fiber stack: Cannot allocate memory (Errno)

Each fiber stack is allocated with a call to mmap, so this is probably reaching the limit of mmaped segments for a single process. In Linux the current limit can be obtained with sysctl vm.max_map_count. Note that not only fibers use mmap, so the actual fibers limit could be much lower than the limit.

The limit can also be increased with sysctl -w vm.max_map_count=NEW_LIMIT. That should change the number of fibers that can be created before that error is raised.

Thanks! I cann’t access the machine yet, so if I can, will try it~ I also had learn the proper way to use fibers in the solution of @ lribeiro.