代码之家  ›  专栏  ›  技术社区  ›  Suma

What to do to make application Large Address Aware?

  •  13
  • Suma  · 技术社区  · 15 年前

    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.

    中列出的开发注意事项 AMD Large Address Aware guide 提供一个良好的起点,但决不完整:

    The following considerations will help to make sure that the code can handle addresses larger than 2GB:

    • 避免使用有符号指针算法(即比较和加法)
    • 指针使用所有32位。不要将bit31用于其他用途。
    • Some dll’s will be loaded just under the 2GB boundary. In this case, no consecutive memory can be allocated with VirtualAlloc().

    因此,问题是: 当C++Win32本地应用程序知道大地址时,需要做什么事情的完整清单?

    1 回复  |  直到 12 年前
        1
  •  24
  •   Community Mohan Dere    8 年前
    • (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.
    • 用getcursorinfo替换所有getcursorpos调用-请参阅 GetCursorPos fails with large addresses
    • 对于pvoid64中的所有分配,请使用ptrtoptr64,例如在使用readfilescatter时,请参见 ReadFileScatter remark section