C#递归深度 - 你有多深可以去 [英] C# Recursion Depth - How Deep can you go

查看:1892
本文介绍了C#递归深度 - 你有多深可以去的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有控制多少,你可以递归调用的东西吗?

这是一个基本的测试程序,我得到的递归深度刚刚超过18K

这依赖于STACKSIZE ......

有没有办法建立一个内存块(可能是一个线程)有一个巨大的堆栈增加递归深度?

解决方案

我在一些文件识别增加堆栈大小。这是真正需要的。

所以,你可以增加堆栈大小的线程使用下面的code:

  VAR的stackSize =千万;
线程线程=新主题(新的ThreadStart(BigRecursion)的stackSize);
 

  

主题(的ThreadStart,Int32)将 -   初始化的新实例   Thread类,指定最大   堆栈大小的线程。

来源

希望这是你所需要的。

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.

Source

Hope this what you need.

这篇关于C#递归深度 - 你有多深可以去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆