我想要产生大量的过程。所以我有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 KiB。
我添加了这个参数--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)或--cfg=contexts/stack-size:100000
...
...
[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).我做错什么了?
发布于 2016-11-21 14:50:00
您是否可以尝试增加系统中每个进程允许的最大映射数的值?
可以使用sysctl -w vm.max_map_count=500000将最大值设置为500000。
我们最近看到,这在一些SMPI运行中引起了一些问题,也许在您的端也是一样的。“无法分配内存”消息可能确实具有误导性,因为ENOMEM错误代码是出于各种原因设置的(根据http://man7.org/linux/man-pages/man2/mprotect.2.html,其中之一可能是映射的数量)。
https://stackoverflow.com/questions/40722615
复制相似问题