C# 中的堆栈容量 [英] Stack capacity in C#

查看:80
本文介绍了C# 中的堆栈容量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我 C# 中的堆栈容量是多少.

Could someone tell me what the stack capacity is in C#.

我正在尝试使用包含 30,000 个项目的数组来形成一个 3D 网格封闭对象.

I am trying to form a 3D mesh closed object using an array of 30,000 items.

推荐答案

.NET 应用程序的默认堆栈大小为 1 MB(32 位 ASP.NET 应用程序的默认堆栈大小为 256 KB,64 位 ASP 的默认堆栈大小为 512 KB.NET 应用程序),但您可以更改它.对于应用程序,您可以通过修改可执行文件的 PE 标头来更改默认大小.对于您创建的线程,您可以使用采用堆栈大小的构造函数重载.

The default stack size for a .NET application is 1 MB (default is 256 KB for 32-bit ASP.NET apps and 512 KB for 64-bit ASP.NET apps), but you can change that. For the application you can change the default size by modifying the PE header of the executable. For threads you create, you can use the constructor overload that takes a stack size.

但正如 Anton Tyjhyy 在他的回答中指出的那样,数组是引用类型,因此位于堆上(即使数组恰好包含一堆值类型).

But as Anton Tyjhyy points out in his answer, arrays are reference types and thus located on the heap (even if the array happens to hold a bunch of value types).

这篇关于C# 中的堆栈容量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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