本文介绍了使用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程序,并在启动该程序后b $ b我确实得到以下结果:

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


  • 千字节物理内存:〜4.000.000KB

  • 千字节的可用物理内存:〜3.200.000KB

  • 正在使用的内存百分比:〜20%

  • 千字节的虚拟地址空间:〜 4.000.000KB¨

  • 千字节的免费虚拟地址空间:〜4.000.000KB

  • Kbytes of physical memory: ~4.000.000KB
  • Kbytes of free physical memory: ~3.200.000KB
  • Percent of Memory in use: ~20%
  • Kbytes of virtual address space: ~4.000.000KB¨
  • Kbytes of free virtual address space: ~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.

如果我要在64bit上编译同一程序具有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 Windows中的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