-4

Background: I'm writing a 2-way installation system (packaging the installation file/ and unpacking and installing the installation file) I make use of BDiff and BPatch (https://github.com/delphidabbler/bdiff). I integrated the Diff code into my app, so I could display progress...

The limitations: 32bit... Delphi 10.1 Berlin, my 7zip solution and my crc solution both need 32bit executable.

The problem: Memory. I will usually Diff 5 exe's of about 40-50Mb each (the Diff,however requires MUCH more memory than 2*filesize), my threadpool only works with 3 threads active otherwise I get out-of-memory errors, that happens ~round 1.5Gb of RAM used

The resources, all promise solution, but could get none to work

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

http://cc.embarcadero.com/item/24309

Using IMAGE_FILE_LARGE_ADDRESS_AWARE 32bit - 64bit

http://docwiki.embarcadero.com/RADStudio/Seattle/en/PE_(portable_executable)_header_flags_(Delphi)

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Linking

My compiler doesn't recognize

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} 

I get [dcc32 Error] MaitreD.dpr(45): E2003 Undeclared identifier: 'IMAGE_FILE_LARGE_ADDRESS_AWARE'

But what is even more disturbing is http://cc.embarcadero.com/item/24309 has a D2009 sample that you can download, and that one, with the same

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} 

compiles with the same RAD studio, so I'm thinking it is some setting that had it's default changed and that the example Delphi project (where the linker directive is working), have other than these default settings;

Finally, the actual question How, in Delphi 10.1 Berlin, do I give my 32bit app full, 4gb, use of memory (I need less than that, but more than the normally limited amount)?

Community
  • 1
  • 1
chillum
  • 123
  • 1
  • 10
  • would the anonymous downvoters care to explain? I put a lot of effort into making the question as clear as possible, or are you downvoting because i am stupid? Anyone could miss that unit – chillum Jul 19 '16 at 16:15
  • My guess is that the down votes are because a majority of the posts you link to explain the solution. It is worth reading error messages carefully and learning how to understand them. This one is pretty clear. The constant isn't defined. So the next question to ask is where it is defined. – David Heffernan Jul 19 '16 at 16:54
  • I didn't know that compiler/linker directives would be in a file you can include in your uses clause, to me the obvious was that somehow my settings of my environment needed changing (because compiler/linker is native to the actual RAD studio, thus asking for /new/ knowledge), not just include another file – chillum Jul 19 '16 at 18:22
  • 5
    The very first link you show us in your question explicitly says "The IMAGE_FILE_LARGE_ADDRESS_AWARE constant is defined in Windows.pas". And even if it didn't, the `uses` clause should always be the first thing to check when encountering this particular error. And since this is a WinApi constant, you can even define it yourself without even using `Windows.pas`. – Jerry Dodge Jul 19 '16 at 18:51
  • @chillum: the *directive* is not declared in Windows.pas, but the flag is. I don't know the exact value of that flag, but I guess the numeric value could be used in the directive as well (can't check, this is written on an iPad). – Rudy Velthuis Jul 20 '16 at 00:26
  • @Rudy: The precise value is mentioned in my answer to the first linked question, where it is also explained that the flag values are defined in Windows.pas. The poster apparently didn't read that answer very well; the Windows unit is mentioned in the second paragraph, following the first code block, and the specific value is mentioned in the first bullet item describing the flags (which is the one this question asks about, BTW). – Ken White Jul 20 '16 at 00:35
  • 1
    @Ken: Ok thanks. So I assume that `{$SETPEFLAGS $0020} works as well? – Rudy Velthuis Jul 20 '16 at 00:44
  • 1
    @Ken: forget that. Just tried it myself and it compiles. I assume it works too (not going to test that right now, at this time of day). – Rudy Velthuis Jul 20 '16 at 00:48

1 Answers1

5

To use that flag, you will have to put Winapi.Windows in your uses clause, because that is where this flag is declared.

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94