本文介绍了使用 IMAGE_FILE_LARGE_ADDRESS_AWARE 32 位 - 64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天了解到在 DelphiXE 中使用编译器指令:

I learned yesterday that in DelphiXE using the compiler directive:

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

即使 DelphiXE 编译器生成 32 位代码,您也可以在 64 位计算机上访问/使用 4GB 地址空间.

you can access/use 4GB address space on 64bit computers even though DelphiXE compiler produces a 32bit code.

我今天在装有 Windows7 的 4GB 机器上尝试了 DelphiXE 程序,并在启动该程序后我真的得到以下结果:

I tried today DelphiXE program on 4GB machine with Windows7 and after starting the program I really get the following result:

  • 物理内存千字节:~4.000.000KB
  • 可用物理内存的 KB:~3.200.000KB
  • 正在使用的内存百分比:~20%
  • 千字节的虚拟地址空间:~4.000.000KB¨
  • KB 的可用虚拟地址空间:~4.000.000KB

每次加载几个对象(表、字符串、列表、大量指针)后的空闲内存下降,什么都好,直到所有内存都用完.一切都很好.但这里有一些问题:

Each time after loading several objects (tables, strings, lists, a lot of pointers) the amoung of free memory goes down, what is fine, untill all memory is used. Everything fine. But here are some questions:

1.有时我会发现程序使用的是硬盘而不是 RAM,因为它变慢了(但内存仍然可用).那可能吗?如果是,当 RAM 仍然可用时,如何防止程序使用光盘?或者,也许一些临时文件被写入光盘?

1.Sometimes I got the filling that program is using hard disc instead of RAM,because it slows down (but the memory is still available).Is that possible? If yes, how to prevent program using disc, when RAM is still available?Or maybe some temporary files are written to disc?

  1. 同样的程序在 8G 内存的机器上会发生什么?32位的程序能不能用全8G?我猜不是,因为指针只有 32 位,而且它们可以访问的内容是有限的.

  1. What would happen with the same program on machine with 8G Ram?Would 32bit program be able to use all 8G?I guess not since pointers are only 32 bits and there is a limit what they can access.

如果我在 64 位机器上用 64 位编译相同的程序编译器(不幸的是,这是不可能的),我的猜测是,在具有 4GRam 的机器上,64 位程序的可用 RAM 空间较少比启用IMAGE_FILE_LARGE_ADDRESS_AWARE"的 32 位程序,因为指针是 64 位的,因此它们单独花费的空间比 32 位指针多.我的想法完全错了吗?

If I would compile the same program on 64bit machine with 64 bitcompiler (what is not possible yet unfortunatelly), my guess is that on machine with 4GRam, 64bit program would have less free RAM space available than 32bit program with "IMAGE_FILE_LARGE_ADDRESS_AWARE" enabled,because pointers are 64bits and therefore they alone spent more space than 32 bit pointers.Am I thinking completelly wrong?

感谢您的回复.

推荐答案

是的,如果操作系统认为有必要,它会将部分虚拟内存(您称为 RAM)交换到页面文件.

Yes, the Operating System will swap parts of your virtual memory (what you call RAM) to the paging file if it decides this is necessary.

一个 32 位程序将不能使用超过 4 GB(即使在 64 位 Windows 上)并且最终一个本机 64 位程序将不会使用比 32 位程序更多的内存,因为指针大小(内部 32 位指针是 x64 窗口中的 64 位指针).

A 32 bit program will not be able to use more than 4 GB (even on 64 bit Windows) and finally a native 64 bit program will not use more memory than a 32 bit program because of the pointer size (internally 32 bit pointer are 64 bit pointers in x64 windows).

附带说明:如果您设置了大地址感知开关,您应该非常确定您的应用程序(包括 vcl、delphi 单元和组件)可以处理大于 2 GB 的地址.例如,将指针转换为 Integer 是不允许的.当然还有更多的陷阱.

And a side note: if you set the Large Address Aware switch you should be really sure that your application (which includes vcl, delphi units and components) can handle addresses > 2 GB. For instance casting a pointer to an Integer is something which is not allowed then. There are more pitfalls of course.

这篇关于使用 IMAGE_FILE_LARGE_ADDRESS_AWARE 32 位 - 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 03:40