我在性能测试期间遇到了这个问题。
使用x86平台标志编译C#控制台应用程序时,未设置Large Address Aware标志:
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是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)地址”标志已设置。
我找不到关于这个主题的任何文件。所有其他堆栈溢出问题建议您必须手动执行此操作:
How to enable IMAGE_FILE_LARGE_ADDRESS_AWARE in C# source code?
Can I set LARGEADDRESSAWARE from within Visual Studio?
Use the 3Gb of memory in 32 bits applications
问题是:这在哪里记录了?
答案 0 :(得分:3)
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.执行此操作的唯一方法是在定位AnyCPU时将二进制标记为大地址识别。此外,如果不是这种情况,那么将Prefer 32位设为默认值是不合适的。
这在哪里记录?
这没有明确记录,暗示。
所有其他堆栈溢出问题建议您必须手动执行此操作
无论所有这些问题和答案如何,只有在定位x86时才需要这样做。