如何为 Windows 中的进程分配超过 2GB 的内存?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6819606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:34:57  来源:igfitidea点击:

How can I allocate more than 2GB of memory to a process in Windows?

c#windowsmemoryprocess

提问by abw333

I am running a program that builds a very large object, and I would greatly benefit from allocating more than 2GB of memory to this process. Thanks in advance.

我正在运行一个构建一个非常大的对象的程序,我将从为这个进程分配超过 2GB 的内存中受益匪浅。提前致谢。

采纳答案by David Heffernan

You appear to be referring to the 2gb limit on virtual memory in 32 bit Windows. You can't get around this limit on a 32 bit system.

您似乎指的是 32 位 Windows 中虚拟内存的 2GB 限制。您无法在 32 位系统上绕过此限制。

回答by Ana Betts

You cannot allocate a single object (or an array) that is greater than 2GB, this is a CLR limitation. You'll have to split up the object into pieces.

您不能分配大于 2GB 的单个对象(或数组),这是 CLR 限制。您必须将对象分成几部分。

回答by Alina Popa

.NET Framework 4.5 allows creating arrays larger than 2GB on 64 bit platforms. This feature is not on by default, it has to be enabled via config file using the gcAllowVeryLargeObjects element.

.NET Framework 4.5 允许在 64 位平台上创建大于 2GB 的数组。默认情况下,此功能未启用,必须使用 gcAllowVeryLargeObjects 元素通过配置文件启用。

http://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx

http://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx