Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I use Embarcadero Delphi XE5 Enterprise Edition. I have a project group consisting of 17 projects. When I click 'Compile All' after 7th compiled project IDE throw me an exception:

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

What is a reason of such error and how to handled with it?

like image 208
Aptem Avatar asked Sep 08 '15 02:09

Aptem


People also ask

What is a system outofmemoryexception?

Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

What type of exception was thrown in ASP NET?

asp.net - Exception of type 'System.OutOfMemoryException' was thrown. - Stack Overflow Exception of type 'System.OutOfMemoryException' was thrown.

What is an oom exception?

Note that an OOM doesn't mean you're out of physical RAM, but that you can't fit a new memory block of the desired size into the address space. And then there are fake OOM exceptions. For example GDI+ returns out-of-memory errors for a wide class of problems including invalid parameters. These are turned into an OOM exception too.

What is the source of an unhandled exception?

Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


1 Answers

The Delphi IDE has several issues managing memory that were never really fixed by Embarcadero, one of the main issue is that the IDE and compiler have huge memory consumption due to caches that are not released between compilation runs.

A workaround that I've applied with success with my codebase is to compile all the projects from the command line with a tool like ANT using the dcc compiler, this will save IDE memory consumption. In the case you need to debug applications then you can compile and build a project at time and restart the IDE every 2/3 compilation.

Another workaround that I've applied successfully in Delphi XE7 to reduce IDE memory consumption was renaming the following IDE files :

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

This makes the XE7 IDE usable again; just the refactoring feature aren’t available anymore.

If the aforementioned solutions don't work for you you will have to split your project group in single projects and switch between project each time as someone else suggested commenting your question.

The new Delphi 10 Seattle seems to address some of these memory related issues since they claim :

“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.

But honestly I don't think it is the definitive solution, is just an improvement of the situation. The final solution of this situation is a 64bit IDE that is not a simple thing to implement by them since I think they have to handle a legacy and not very flexible codebase ...

Try the new Delphi 10 and see if the situation improve, if not apply the workaround and wait for a 64bit IDE release.

like image 93
aleroot Avatar answered Oct 16 '22 23:10

aleroot