如何更改 .NET 程序的堆栈大小? [英] How to change stack size for a .NET program?

查看:28
本文介绍了如何更改 .NET 程序的堆栈大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行 20 亿次递归调用和堆栈溢出的程序.我进行了更改,然后它仍然需要 40K 递归调用.所以我可能需要几 MB 堆栈内存.我听说堆栈大小默认为 1MB.我尝试在网上搜索.有人说去属性->链接器……在visual studio中,但我找不到.

I have a program that does recursive calls for 2 billion times and the stack overflow. I make changes, and then it still need 40K recursive calls. So I need probably several MB stack memory. I heard the stack size is default to 1MB. I tried search online. Some one said to go properties ->linker .........in visual studio, but I cannot find it.

有人知道怎么增加吗?另外我想知道是否可以在我的 C# 程序中设置它?

Does anybody knows how to increase it? Also I am wondering if I can set it somewhere in my C# program?

附:我使用的是 32 位 winXP 和 64 位 win7.

P.S. I am using 32-bit winXP and 64bit win7.

推荐答案

从 .NET 2.0 和 Win XP 开始设置堆栈大小的最简单方法是使用您想要的堆栈大小生成一个新线程:-

The easiest way to set the stack size from .NET 2.0 and Win XP onwards is to spawn a new thread with the stack size you'd like:-

using System.Threading;

Thread T = new Thread(threadDelegate, stackSizeInBytes);
T.Start();

要更改整个程序的堆栈大小,您必须使用 editbin:-

To change the stack size of the entire program you'd have to use editbin:-

EDITBIN.EXE /STACK:<stacksize> file.exe

这篇关于如何更改 .NET 程序的堆栈大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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