哪个系统? 单论 Windows 的话,有: 设置栈大小: https://learn.microsoft.com/en-us/cpp/build/reference/stack-stack-allocations 设置堆大小: https://learn.microsoft.com/en-us/cpp/build/reference/heap BSD 与 Linux ,可以自己设栈大小: https://stackoverflow.com/questions/2275550/change-stack-size-for-a-c-application-in-linux-during-compilation-with-gnu-com https://linux.die.net/man/2/setrlimit https://man.freebsd.org/cgi/man.cgi?query=setrlimit 关键点:setrlimit(RLIMIT_STACK 至于堆大小,那就把 RLIMIT_STACK 换成 RLIMIT_AS