"Exception of type 'System.OutOfMemoryException' was thrown" 同时编译多个项目时

"Exception of type 'System.OutOfMemoryException' was thrown" when compiling several projects at once

我使用 Embarcadero Delphi XE5 企业版。我有一个由 17 个项目组成的项目组。当我在第 7 个编译项目 IDE 后单击 'Compile All' 时抛出异常:

[Fatal Error] Exception of type 'System.OutOfMemoryException' was thrown.

出现这种错误的原因是什么,如何处理?

Delphi IDE 有几个管理内存的问题,Embarcadero 从未真正解决过这些问题,主要问题之一是 IDE 和编译器由于内存消耗巨大 到编译运行之间未释放的缓存。

我在我的代码库中成功应用的解决方法是使用 dcc 编译器使用 ANT 等工具从命令行编译所有项目,这将节省 IDE 内存消耗。如果您需要调试应用程序,那么您可以随时编译和构建一个项目,并在每 2/3 次编译后重新启动 IDE。

我在 Delphi XE7 中成功应用以减少 IDE 内存消耗的另一个解决方法是重命名以下 IDE 文件:

  • Borland.Studio.Delphi.dll
  • Borland.Studio.Refactoring.dll
  • refactoride210.bpl

这使得 XE7 IDE 再次可用;只是重构功能不再可用。

如果上述解决方案对您不起作用,您将不得不将您的项目组拆分为单个项目,并且每次在其他人建议评论您的问题时在项目之间切换。

新的 Delphi 10 Seattle 似乎解决了其中一些与内存相关的问题,因为他们声称:

“Under the hood” the IDE’s project, file, and build management handling has gone through a major overhaul and redesign to provide significantly extended available memory, giving developers a more stable, capable, and faster development experience.

但老实说,我认为这不是最终的解决方案,只是对情况的改进。这种情况的最终解决方案是 64 位 IDE,这对他们来说不是一件容易实现的事情,因为我认为他们必须处理遗留且不是很灵活的代码库 ...

尝试新的 Delphi 10,看看情况是否有所改善,如果没有改善,请应用解决方法并等待 64 位 IDE 版本。