0

I'm migrating a Delphi 2007 runtime only project to Delphi XE7. In Delphi XE7, when compiling, it often raises the following error:

enter image description here

Can't load package MyPackage.bpl.

Risorse di memoria disponibili insufficienti per elaborare il comando.

(translated) Not enough memory resources are available to process this command.

And sometimes it raises this other error:

[dcc32 Fatal Error] MyPackage.dpk(682): F2046 Out of memory

The project is very big (it contains 610 units with very complex forms) and I think I should split it into smaller projects but I'm wondering...

When the error occurs, I have to close and reopen the IDE, otherwise it will always show the error on next compile attempts. On the other side, the error never occurs when compiling using the msbuild from command line.

Is it really necessary? Is there something that can be done in order to avoid this kind of problem without dividing the sources in multiple packages?

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
  • Why does compiling a project result in a package being loaded? Is this a designtime package? Do you really have 610 units with complex forms in a designtime package? – David Heffernan Nov 15 '19 at 09:26
  • @DavidHeffernan: I really don't know, it's a runtime only project – Fabrizio Nov 15 '19 at 09:45
  • @MartynA: No, I'll try. Could you please address me to some documentation about that? – Fabrizio Nov 15 '19 at 09:47
  • Do you know what MyPackage.bpl is? – David Heffernan Nov 15 '19 at 09:55
  • @DavidHeffernan: What do you mean? It's a runtime only package containing forms. At runtime I load it from my application dynamically, by calling LoadPackage function, then I call GetClass and create the forms instances. – Fabrizio Nov 15 '19 at 10:03
  • @MartynA: Ok but MyPackage is a runtime-only package – Fabrizio Nov 15 '19 at 10:04
  • You said that you encounter the error "when compiling". Is that statement incorrect? – David Heffernan Nov 15 '19 at 10:31
  • @DavidHeffernan: No, it's correct, I get the error on compiling. The ide displays the error in the "Messages" area (like warnings, hints, errors...) – Fabrizio Nov 15 '19 at 10:40
  • OK, so if this is a runtime package, why is the compiler trying to load it during compilation? Or is this just a misleading error message from the compiler? – David Heffernan Nov 15 '19 at 10:48
  • @DavidHeffernan: I think it's a misleading error message, I've created the project from scratch when migrating it to Delphi XE7, so it has default settings except for the output directories. Furthermore, it is not used by any other installed package and it has no build events. When the error occurs, I have to close and reopen the IDE, otherwise it will always show the error on next compile attempts – Fabrizio Nov 15 '19 at 11:48
  • @DavidHeffernan: I've noticed that the error never occurs when compiling using [msbuild](http://docwiki.embarcadero.com/RADStudio/Rio/en/Building_a_Project_Using_an_MSBuild_Command) from command line – Fabrizio Nov 15 '19 at 11:54
  • It's probably just the well known problem that 32 bit Delphi IDE consumes too much memory when compiling. This was slightly improved in later releases, but the problem still remains to a degree. I think you just need to get used to killing the IDE regularly. An upgrade might help. – David Heffernan Nov 15 '19 at 12:20
  • If you have plenty of Tabs (units) open, try closing some of them and compile it again. – MaGiC Nov 15 '19 at 12:41
  • Maybe this is silly, but... are you maybe just running out of memory? How much do you have on the development system? How much is free when you're trying to compile? Maybe an [atom leak](https://stackoverflow.com/a/9066509/327083)? – J... Nov 15 '19 at 13:25
  • @J... That's not how it works. There is swap space. Remember that the Delphi IDE runs as a 32 bit process and XE7 isn't large address aware. So regardless of how much memory is on the system, the process can only address 2gb. – David Heffernan Nov 15 '19 at 13:39
  • @DavidHeffernan Yes but if OP is running a P4 on XP with 512MB of memory and swap disabled (I've seen crazier...) then the 2GB limit is a bit ethereal. Fragmentation, also? – J... Nov 15 '19 at 14:02
  • @J... Seems unlikely. And we know that XE7 routinely exhausts address space, even on moderately sized projects. – David Heffernan Nov 15 '19 at 14:40
  • I have a big project as well, (3000+ units of which ~1000 forms). The project group contains some other projects as well, including a library, a test project, and some 'offspring' tools that depend on the big project. When I try to build them all, I also get that (or a similar) error. MSBuild works fine as well (we use that in the deployment pipeline too), but it's way slower. It's as if Delphi's own compilation process is keeping stuff in memory throughout the build process for multiple projects. Or there is some freaky leak somewhere. I'm on Delphi 10 Seattle, by the way. – GolezTrol Nov 15 '19 at 17:35
  • Have you tried using [Delphi IDE Fix Pack](https://www.idefixpack.de/blog/ide-tools/ide-fix-pack/)? It fixes several compiler problems. And if my memory serves me correctly it reduces memory requirement during compilation to a degree. – SilverWarior Nov 15 '19 at 18:24
  • I would also suggest using Delphi IDE Fix Pack and combine it, with the use of DDevExtensions. Check the option Compilations --> "Release compiler unit cache of other projects before compiling". @GolezTrol, i had a similar problem when i had migrated my project group from 2010 to XE7, The use of that option allowed me to build all of the project. – stmpakir Nov 18 '19 at 14:05
  • Computer has 16 GB RAM. I've installed the Delphi IDE Fix Pack but the problem still occurs and it also happens with the MyPackage project only (no project group, and compiling only the MyPackage project) – Fabrizio Nov 20 '19 at 13:15

0 Answers0