使用任何 CPU 集编译 C# 应用程序可以处理大(> 2GB)地址 [英] Compiling C# with Any CPU sets Application can handle large (>2GB) addresses

查看:8
本文介绍了使用任何 CPU 集编译 C# 应用程序可以处理大(> 2GB)地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在性能测试期间遇到了这个问题.

I ran into this issue during performance testing.

使用 x86 平台标志编译 C# 控制台应用程序时,未设置大地址感知标志:

When compiling a C# Console application with the x86 platform flag, the Large Address Aware flag is not set:

dumpbin/headers app.exe 的输出:

Output from dumpbin /headers app.exe:

Dump of file app.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        569F0089 time date stamp Tue Jan 19 21:35:37 2016
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
             102 characteristics
                   Executable
                   32 bit word machine

将标志设置为Any Cpu"时,生成的 exe 是大地址感知的:

When setting the flag to "Any Cpu" the resulting exe is Large Address Aware:

Dump of file app.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        569F01D7 time date stamp Tue Jan 19 21:41:11 2016
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
              22 characteristics
                   Executable
                   Application can handle large (>2GB) addresses

请注意,应用程序可以处理大 (>2GB) 地址"标志已设置.

Notice that the "Application can handle large (>2GB) addresses" flag is set.

我找不到有关此主题的任何文档.所有其他堆栈溢出问题都建议您必须手动执行此操作:

I cannot find any documentation on this subject. All other stack overflow questions suggest you must do this manually:

如何在C#源代码中启用IMAGE_FILE_LARGE_ADDRESS_AWARE?

我可以在 Visual Studio 中设置 LARGEADDRESSAWARE 吗?

在 32 中使用 3Gb 的内存位应用

问题是:这是在哪里记录的?

推荐答案

AnyCPU 的目的是能够在 x86 和 x64 平台上运行托管代码,同时利用更大的x64 平台的地址空间. 这样做的唯一方法是在面向 AnyCPU 时将二进制文件标记为大地址感知.此外,如果不是这种情况,则将 Prefer 32 位设为默认值是不合适的.

The purpose of AnyCPU is to be able to run managed code on both x86 and x64 platforms while at the same time take advantage of the larger address space of x64 platforms. The only way to do this is to mark the binary as large address aware when targeting AnyCPU. In addition, if this was not the case, it would have not been appropriate to make Prefer 32-bit the default.

这是在哪里记录的?

这没有被明确记录,它是隐含的.

This has not been explicitly documented, it's implied.

所有其他堆栈溢出问题都建议您必须手动执行此操作

All other stack overflow questions suggest you must do this manually

不管所有这些问题和答案,只有在面向 x86 时才需要这样做.

Irrespective of all of those questions and answers, this is required only when targeting x86.

这篇关于使用任何 CPU 集编译 C# 应用程序可以处理大(> 2GB)地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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