本文介绍了如何做到使应用程序大地址感知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在进行我们的应用程序大地址感知。根据经验表明,这样做有一些意想不到的困境。我创建此帖子以制定需要执行的步骤的完整列表。
I am currently in process of making our application Large Address Aware. As experience has shown, there are some unexpected gotchas when doing so. I create this post to make a complete list of steps which need to be taken.
提供了一个很好的起点,但并不完整:
The development considerations listed in the AMD Large Address Aware guide provide a good starting point, but are by no means complete:
- 避免使用带符号的指针运算(即比较和添加)
- 指针使用所有32位。不要使用Bit31的东西。
- 某些dll将被加载在2GB边界下。
- 尽可能使用GlobalMemoryStatusEx()(首选)或GlobalMemoryStatus()来检索内存大小。
- Avoid the use of signed pointer arithmetic (I.e. compares and adds)
- Pointers use all 32-bits. Don’t use Bit31 for something else.
- Some dll’s will be loaded just under the 2GB boundary. In this case, no consecutive memory can be allocated with VirtualAlloc().
- Whenever possible, use GlobalMemoryStatusEx() (preferred) or GlobalMemoryStatus() to retrieve memory sizes.
因此,问题是:在制作C ++时需要做的事情的完整列表是什么Win32本机应用程序大地址感知?
推荐答案
- 在项目属性中的大于2千兆字节(/ LARGEADDRESSAWARE):链接器/系统/启用大地址
- 检查所有指针减法并验证结果存储在可能包含可能差异的类型,或者用比较或其他结构替换它们 - 请参见 )。注意:指针比较应该很好,与AMD的建议相反,没有理由为什么它应该导致4 GB的问题
- 确保你不假设指针有Bit31零,不要尝试
- 使用GetCursorInfo替换所有GetCursorPos调用 - 参见
- (obvious) select Support Address Larger than 2 Gigabytes (/LARGEADDRESSAWARE) in the project properties: Linker / System / Enable Large Address
- check all pointer subtractions and verify the result is stored in a type which can contain the possible difference, or replace them with comparisons or other constructs - see Detect pointer arithmetics because of LARGEADDRESSAWARE). Note: pointer comparison should be fine, contrary to AMD advice, there is no reason why it should cause 4 GB issues
- make sure you are not assuming pointers have Bit31 zero, do not attempt to use Bit31 for something else.
- replace all GetCursorPos calls with GetCursorInfo - see GetCursorPos fails with large addresses
- for all assignments into PVOID64 use PtrToPtr64, needed e.g. when using ReadFileScatter, see ReadFileScatter remark section
这篇关于如何做到使应用程序大地址感知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!