Visual Studio Express: fatal error c1060, the compiler is out of heap space
Asked Answered
R

8

19

I'm trying to build a program from its source code with VC 11. When the compiler is about to finish, it raises the error mentioned in title of this post.

As I've read here and in other forums, I tried to both close as many programs as possible and enlarge the size of the swap file in Windows... neither works.

I've read about a parameter called \Zm but I don't understand how to use it.

Can you please help me?

Respire answered 28/5, 2014 at 16:26 Comment(4)
Explanations about how to use the /Zm flag are here: msdn.microsoft.com/en-us/library/bdscwf1c.aspxArguelles
Thank you but I had already read it. The fact is that I compile through command line with cmake and the with nmake...not with the ideRespire
How much memory the compiler is taking? You can look in the task manager (cl.exe)Encephalograph
Is it possible to run the 64-bit toolset? That often fixes the heap space issues that cause C1060. (If you still have heap issues when running the 64-bit toolset, something else could be wrong with your precompiled header.) There's some discussion in How to: Enable a 64-Bit Visual C++ Toolset on the Command Line though I admit to not being familiar with how that interacts with cmake.Aliciaalick
S
11

Take a look at this documentation which gives possible solutions:

I also had that problem and found the documentation useful. Main points:

  1. If the compiler also issues errors C1076 and C3859, use the /Zm compiler option to lower the memory allocation limit. More heap space is available to your application if you lower the remaining memory allocation.

    If the /Zm option is already set, try removing it. Heap space might be exhausted because the memory allocation limit specified in the option is too high. The compiler uses a default limit if you remove the /Zm option.

  2. If you are compiling on a 64-bit platform, use the 64-bit compiler toolset. For information, see How to: Enable a 64-Bit Visual C++ Toolset on the Command Line.

  3. On 32-bit Windows, try using the /3GB boot.ini switch.

  4. Increase the size of the Windows swap-file.

  5. Close other running programs.

  6. Eliminate unnecessary include files.

  7. Eliminate unnecessary global variables, for example, by allocating memory dynamically instead of declaring a large array.

  8. Eliminate unused declarations.

  9. Split the current file into smaller files.

Seely answered 21/10, 2016 at 10:37 Comment(1)
For me, using the 64-bit compiler toolset was the best option.Planchette
E
4

I can't tell much about the /Zm parameter, but I had the same issue (compiler is out of heap space).

What has helped me was the /m:4 (4 for the count of your CPUs) parameter so that you can use multiple CPUs for building.

Hope that helps you as well.

Also, if you are running on x64, be sure that the x64 version of "msbuild.exe" and "cl.exe" is beeing used. I had the issue that even when using e.g. the x64 ms powershell, the compiler would still choose the 32-bit version of msbuild.exe (in task manager "msbuild.exe*32", windows 7)

Eris answered 20/9, 2017 at 9:30 Comment(0)
C
4

In addition to the other answers here (and in my case), fatal error C1060: compiler is out of heap space can be caused by a syntax error. The following code (in certain circumstances) can cause this error even with correct compiler options -- for instance if you've previously successfully compiled the same program.

r.push_back(e[1];

instead of

r.push_back(e[1]);

It seems to only cause this error rather than the standard error C2143: syntax error: missing ')' before ';' when r and e are of certain types, but it's worth checking any code you've edited recently if the program previously compiled without errors.

Curtate answered 23/2, 2018 at 15:9 Comment(0)
S
2

We had similar problem: a relativelly simple program (although, full of templates, using Eigen library) persistently failed to compile on one of the computers. All were using MSVC2013 x64, but only one was unable to compile the program due to C1060 error. We tried different compiler flags, setting/unsetting -Zm, but failed to resolve it without modifying code.

Some pointers were, however, given to us, when we switched from x64/x64 (64bit compiler for 64bit resulting executable) version of the compiler to the x86/x86 (32bit compiler for 32bit resulting executable). The x86 compiler gave us exact locations of the problematic parts of the program - calls to template functions receiving heavy templated objects. We have rewritten those to normal functions (build in different object file) and that solved the problem...

Schnapp answered 6/11, 2017 at 21:19 Comment(0)
S
2

VS: Visual Studio 2015 OS: Windows10

If you are using VS2015 as your IDE, maybe there is another solution: Go to update the VS2015 "Update3" package and everything will work smoothly.

Smallage answered 29/11, 2019 at 1:35 Comment(0)
F
1

In my case, a main program would not compile is VS 2022 Community Edition (free). It had many include files. By process of elimination, I managed to compile it once I removed any "volatile" modifiers in declarations that had this modifier. A very strange bug, to say the least!

Foolproof answered 24/3, 2022 at 21:17 Comment(0)
V
1

I got this error when compiling OnnxRuntime with MS Visual C++ 17 2022.

The solution for this issue was to close all other programs and compile using a single thread (in this case, removing the --parallel argument from the build.bat call).

Voltaic answered 26/1, 2023 at 15:5 Comment(0)
O
1

Solved it by editing the maximum number of compiler instances in VS 2022

Tools -> Options -> Projects and Solutions -> VC++ Project Settings -> Maximum concurrent C++ compilations

Offcolor answered 18/1 at 17:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.