Reputation: 22163
I am playing with lambda calculus and would like to have a bit more stack space to be able to build and compute (very) long function chains. Is there a way to increase it for the crate, similar to increasing the recursion limit (#![recursion_limit = "100"]
)?
The crate is a library and I would like it to be able to perform stack-intensive operations regardless of the target operating system.
Upvotes: 7
Views: 7163
Reputation: 22163
After some research I concluded that there isn't a universal way to achieve what I am after, but using std::thread::Builder
I was able to create an extra thread with a specified stack size and perform stack-heavy operations inside it:
fn huge_reduction() {
let builder = thread::Builder::new()
.name("reductor".into())
.stack_size(32 * 1024 * 1024); // 32MB of stack space
let handler = builder.spawn(|| {
// stack-intensive operations
}).unwrap();
handler.join().unwrap();
}
Upvotes: 11
Reputation: 430348
This is not a language feature, it's an operating system feature. On *nix systems, you will use a tool like ulimit
. Other systems likely use other tools:
Upvotes: 4