[fpc-devel]Memory exhausted

Peter Vreman peter at freepascal.org
Wed Apr 4 18:09:06 CEST 2001

> Hello,
> >> I think this is all happening because of unit interdependencies... Maybe
> >> it is really necessary to implement something new in this field?
> > 
> > Try compiling with -Ca, this will set all registers to used for each procedure.
> Yes, this helped. But that's strange compiler cannot catch all the
> changes after the first pass.

Because of the interdependency. Recompiling everything internal until it convergences will
take to much time for a first compile. For the compiler itself it'll take 5-6 compiles
before only pp.pas is compiled.

A small example with 2 units and 1 program:

unit A
from interface uses B

unit B
from implementation uses A

program C
uses A

Compiling program C will result:
- load units from C
- load interface units from A
  - load unit B
  - load interface units from B
  - load implementation units from B
    - unit A is already loaded, parse the interface of A
  - compile unit B storing the checksum of the interface from unit A
- back in unit A, compile the unit and write checksum from B
- compile program C

A second compile of C will result in:

When there was a routine in unit A that didn't use all registers then unit B will
recompile, because it can possible be optimized. This change can lead to unit A want to
recompile the next time again when a third recompile is done.

Hope this example makes it a little bit clear how complex everything is. Also note that
there are more things to take care of like memory leakes and open files!

More information about the fpc-devel mailing list