How can I enable my 32-bit Delphi application to use 4gb of memory on 64-bit windows (via Wow64.exe)?

Mick picture Mick · Dec 4, 2009 · Viewed 12.8k times · Source

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?

Answer

gabr picture gabr · Dec 4, 2009

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}