C# 递归深度 - 你能走多远 [英] C# Recursion Depth - How Deep can you go
问题描述
是否可以控制递归调用的次数?
从一个基本的测试程序中,我得到了超过 18k 的递归深度
这取决于堆栈大小....
有没有办法设置一块内存(可能是一个线程)和一个巨大的堆栈来增加递归深度?
我在某些文档识别过程中增加了堆栈大小.真的很需要.
因此您可以使用以下代码增加线程的堆栈大小:
var stackSize = 10000000;线程线程 = new Thread(new ThreadStart(BigRecursion), stackSize);
<块引用>
Thread(ThreadStart, Int32) --初始化一个新的实例线程类,指定最大值线程的堆栈大小.
希望这是你需要的.
Is there any control how much you can Recursively call something?
From a basic test program I get a recursion depth of just over 18k
which depends on the stacksize....
is there a way to set up a chunk of memory (perhaps a thread) with a massive stack to increase recursion depth?
I've increased the stack size during some documents recognition. It was really needed.
So you can increase stack size for thread using following code:
var stackSize = 10000000;
Thread thread = new Thread(new ThreadStart(BigRecursion), stackSize);
Thread(ThreadStart, Int32) -- Initializes a new instance of the Thread class, specifying the maximum stack size for the thread.
Hope this what you need.
这篇关于C# 递归深度 - 你能走多远的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!