2016-11-21 108 views
1

我想产卵量很大的过程。所以我有master这个过程。产卵量大的过程

int master(int argc, char* argv[]){ 
    for (int i = 0; i < 50000; ++i) { 
     std::string name = std::to_string(i); 
     MSG_process_create(name.c_str(), slave, NULL, MSG_host_self()); 
    } 
    return 0; 
    } 

int slave(int argc, char* argv[]){ 
    XBT_INFO("%s", MSG_process_get_name(MSG_process_self())); 
    return 0; 
} 

后,我推出这个节目,我有以下的输出:

.... 
.... 
[Master:32734:(32736) 0.000000] [master/INFO] 32734 
[Master:32735:(32737) 0.000000] [master/INFO] 32735 
[0.000000] /home/ken/Downloads/simgrid-master/src/simix/smx_context.cpp:187: [xbt/CRITICAL] Failed to protect stack: Cannot allocate memory 

Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 

然后,我建议使用contexts/stack-size参数更改堆栈大小,因为默认情况下,前面的程序需要50000 * 8192昆明植物研究所。

我加入这个参数--cfg=contexts/stack-size:10但我有相同的输出:

... 
... 
[Master:32735:(32737) 0.000000] [master/INFO] 32735 
[0.000000] /home/ken/Downloads/simgrid-master/src/simix/smx_context.cpp:187: [xbt/CRITICAL] Failed to protect stack: Cannot allocate memory 

Process finished with exit code 134 (interrupted by signal 6: SIGABRT) 

或者:

... 
... 
[Master:32734:(32736) 0.000000] [master/INFO] 32734 
[0.000000] /home/ken/Downloads/simgrid-master/src/simix/smx_context.cpp:187: [xbt/CRITICAL] Failed to protect stack: Cannot allocate memory 

这似乎是我的程序没有看到这个参数,但它不是”因为堆栈参数是5给我:

Finally, if nothing of the above applies, this can result from a stack overflow. 
Try to increase stack size with --cfg=contexts/stack_size (current size is 1 KiB). 

我做错了什么?

回答

2

你可以尝试增加系统上每个进程允许的最大映射数值吗?

你可以做到这一点与须藤的sysctl -w vm.max_map_count = 500000设定的最大值500000

最近,我们看到,这是造成一些问题上的一些SMPI运行,也许这是您的最终同。由于各种原因(根据http://man7.org/linux/man-pages/man2/mprotect.2.html,其中之一可能是映射的数量)设置了ENOMEM错误代码,“无法分配内存”消息可能确实是误导性的。