7

My (quite large) C++ project has grown to a point where I get a C1060: compiler is out of heap space error when trying to compile my project.

I'm compiling on a 64-bit Windows 10 machine, but it seems that Visual Studio is compiling my project with the 32-bit toolset (see screenshot below).

32 bit compiler driver

The C1060 help page asks me to use the 64-bit toolset, but the link provided talks about how to enable it when compiling with the command line only.

Is there any way to set project properties or something else in Visual Studio 2017 to tell it to use the 64-bit compiler toolset (which is already installed on my machine)?

Rakete1111
  • 47,013
  • 16
  • 123
  • 162
Bernard
  • 5,209
  • 1
  • 34
  • 64
  • 3
    Having the *compiler* exceed 3 GB of address space looks to me a symptom of a pathological code base... It doesn't really matter how big overall your project is, if you modularize it properly each translation unit should be manageable. – Matteo Italia Sep 05 '17 at 13:34
  • 1
    @MatteoItalia I agree, the bulk of the code is in one translation unit with lots of templates and headers, and it's kind of messy. But for now, I don't have the time to refractor the code base. – Bernard Sep 05 '17 at 13:37
  • For some strange reason, when I have defined `template using constant_not = std::bool_constant<!(TBoolConstant::value)>;`, the compiler becomes very memory hungry when I have a `constant_not{}`. If I change the definition to `template using constant_not = std::bool_constant<!bool(TBoolConstant::value)>;`, the memory falls to a very manageable 300MB. Possibly a compiler bug, but I will have to do more tests. – Bernard Sep 10 '17 at 15:06

1 Answers1

9

This is how I made Visual Studio 2017 use the x64 toolset, as per this answer:

Open the .vcxproj file with your favourite text editor, find this line:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

Then add this immediately after it:

<PropertyGroup>
  <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>

That answer was for Visual Studio 2013 but it works for 2017 too.

Additional Note: However, it turns out this didn't actually solve my problem. The 64-bit toolset ate up all the memory on my machine and forced me to need to reboot. When I rolled back the latest changes to the code, it compiles using ~2.8GB for the 32-bit compiler, and compiles using ~4.2GB for the 64-bit compiler (the latest code consumed ~6.4GB before freezing my task manager on my 8GB machine). I'll be looking through the new code and attempting to figure out why so much more memory was needed.

Bernard
  • 5,209
  • 1
  • 34
  • 64