Search code examples
delphidelphi-5

Compiler directive SETPEFlags in Delphi 5


I have one application which is built using Delphi 5.0 and works fine without any issues. But when running a large report, my application needs more than 2 GB of memory. After doing an analysis, I found that using the compiler directive SetPEFlags can increase my 32-bit application memory up to 4 GB.

I am trying to set the flag in my program in Delphi 5.0 but I'm getting an "Invalid Compiler Directive" error. Can somebody suggest any way to resolve this without rebuilding the application in another version? Or, what version was SetPEFlags added to Delphi?


Solution

  • You can't get the tools in Delphi 5 to mark your application as Large Address Aware ({$SetPEFlags} was added in Delphi 6). You need to add that PE flag as a post build setting. The usual way to set that flag is to use Microsoft's editbin tool.

    Once you do this, your program will stop working as soon as you allocate memory beyond the 2GB boundary. That's because the default Borland memory manager does not support large addresses. You will need to replace it with FastMM or other LAA-capable memory manager. Or you can write your own replacement memory manager using, for instance, HeapAlloc(), if you wish.