12345678_0001
要超出setrlimit中的硬限制(在OSX上默认只有64MB),请使用具有选择的堆栈大小的pthreads创建一个新线程。这是一个C代码段: // Call function f with a 256MB stack. static int bigstack(void *(*f)(void *), void* userdata) { pthread_t thread; pthread_attr_t attr; // allocate a 256MB region for the stack. size_t stacksize = 256*1024*1024; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, stacksize); int rc = pthread_create(&thread, &attr, f, userdata); if (rc){ printf("ERROR: return code from pthread_create() is %d\n", rc); return 0; } pthread_join(thread, NULL); return 1; }