开发者

Using IMAGE_FILE_LARGE_ADDRESS_AWARE 32bit - 64bit

开发者 https://www.devze.com 2023-01-21 09:08 出处:网络
I learned yesterday that in DelphiXE using the compiler directive: {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

I learned yesterday that in DelphiXE using the compiler directive:

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

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

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

  • 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. B开发者_如何学Cut here are some questions:

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. 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.

  2. If I would compile the same program on 64bit machine with 64 bit compiler (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?

Thanks for any reply.


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.

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).

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.


64 bit applications use some more memory than 32 bit ones, because some data types will be 64 bit long instead of 32 (not only pointers - and that depends on what datatypes your applications uses and compiler standard types). Also some instructions may requires more bytes to be coded. As UTF-16 strings require more space than ANSI ones. Of course if you have to manipulate large 64 bit structures is not a good idea to use a 64 bit machine with 4GB RAM only. One of the reason to use a 64 bit OS is to manage more than 4GB without using any pagination trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消