Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-07

x64 compiler and Large Address Aware flag

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

OBones

Hello,

We are using FPC (2.6.0) here to allow compiling our users ideas into runable code and while this has worked just fine until now, on one occasion we have reached a situation where the ppcrossx64 compiler ends with an EOutOfMemory exception.
Looking at its memory consumption, sure enough, it reaches 1.2G of RAM used and then dies with the exception.
If we rerun it with the same options, it then consumes 1G and finishes successfully with a valid DLL file.
The project we make it compile is made of 464 pas files, totaling 180M on the hard drive. Once compiled, the .o and .ppu files use 650M on the hard drive, while the DLL uses 124M.
Here is the command line we are using:

ppcrossx64 -Mdelphi -Fu..\units\x86_64-win64\fcl-base -Fu..\units\x86_64-win64\rtl -Fu..\units\precompiled1\x86_64-win64 -Fu..\units\precompiled2\x86_64-win64 Project.dpr

I don't see any issue with the command line and the number of files does not seem that high to me.
As a workaround, I patched ppcrossx64.exe so that its PE header includes the Large Address Aware flag thus meaning it can now use up to about 3G of RAM instead of roughly 1.5
Once patched, I removed all .ppu and .o files and reran the same command line. This time it finished successfully at first run and observing it, it used 1.4 G of RAM at most during its execution.

I have used this flag in various projects for quite a while now and could not see any adverse effect, except in extreme corner cases where weird pointer arithmetic was used and more than 2G of RAM was in use.

Do you think it is safe to use the patched ppcrossx64 compiler?

Thanks a lot for your opinions.

Olivier

Jonas Maebe
to OBones

OBones wrote on Wed, 27 Jul 2016:

Show quoted text 8 lines
I don't see any issue with the command line and the number of files does not seem that high to me. As a workaround, I patched ppcrossx64.exe so that its PE header includes the Large Address Aware flag thus meaning it can now use up to about 3G of RAM instead of roughly 1.5 Once patched, I removed all .ppu and .o files and reran the same command line. This time it finished successfully at first run and observing it, it used 1.4 G of RAM at most during its execution.

[snip]

Do you think it is safe to use the patched ppcrossx64 compiler?

Normally, yes. We try to avoid casting pointers to signed integers, and the compiler in fact warns if you do that. So pointers >= pointer($80000000) should be handled correctly by both the compiler and the RTL.

Jonas