According to this MSDN page:
WOW64 enables 32-bit applications to take advantage of the 64-bit kernel. Therefore, 32-bit applications can use a larger number of kernel handles and window handles. However, 32-bit applications may not be able to create as many threads under WOW64 as they can when running natively on x86-based systems because WOW64 allocates an additional 64-bit stack (usually 512 KB) for each thread. In addition, some amount of address space is reserved for WOW64 itself and the data structures it uses. The amount reserved depends on the processor; more is reserved on the Intel Itanium than on the x64 processor.
If the application has the IMAGE_FILE_LARGE_ADDRESS_AWARE flag set in the image header, each 32-bit application receives 4 GB of virtual address space in the WOW64 environment. If the IMAGE_FILE_LARGE_ADDRESS_AWARE flag is not set, each 32-bit application receives 2 GB of virtual address space in the WOW64 environment.
How do I effectively set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag in my Delphi 2007 application so that I can make my 32-bit application Wow64 aware and address up to a full 4GB of memory?
One of the simplest ways to increase the amount of memory a process can use on 32-bit Windows is to enable the /3GB flag in the Windows' boot. ini file. This has the effect of adjusting the kernel/user address space split in favour of the application by 1GB, i.e. instead of a 2GB/2GB split you have a 3GB/1GB split.
Anyway, the "only" limitation a 32-bit program has is that it cannot map more than 4GB at once. But you can easily extend it through shared memory.
To support more than 4 GB memory Windows uses Physical Address Extension (PAE). It uses paging tables to map the memory greater than 4 GB. By doing this the physical address size is increased to 36 bits, or 64 GB. PAE is used in 64-bit OS'es as well; in this case the maximum size is doubled to 128 GB.
What are the RAM limits of a 32-bit operating system? All 32-bit operating systems have a 4GB RAM limit.
See this CodeCentral article: Using more than 3 GB memory in a 32 bit Delphi program.
In modern Delphi versions just add compiler directive to the dpr:
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
Use the linker directive $SetPEFlags:
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
The IMAGE_FILE_LARGE_ADDRESS_AWARE
constant is defined in Windows.pas. I don't remember which Delphi version first included it, though.
In Delphi 2007, you'll find SetPEFlags documented in "PE (portable executable) header flags (Delphi)".
Some useful IMAGE_FILE_HEADER
flags:
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} //$0020
Application can handle addresses larger than 2 GB.
{$SetPEFlags IMAGE_FILE_NET_RUN_FROM_SWAP} //$0800
If the image is on the network, copy it to and run it from the swap file.
{$SetPEFlags IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP} //$0400
If the image is on removable media, copy it to and run it from the swap file.
Some IMAGE_FILE_HEADER flags:
{$SetPEOptFlags IMAGE_DLLCHARACTERISTICS_NX_COMPAT} //$0100
The image is compatible with data execution prevention (DEP).
{$SetPEOptFlags IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE} //$0040
The DLL can be relocated at load time. (aka ASLR - Address Space Layout Randomization)
{$SetPEOptFlags IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE} //$8000
The image is terminal server aware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With