Today I've been adding some library headers to our precomp.h
file. Then I tried to recompile in debug and got those two errors (spawned from a boost include):
error C3859: virtual memory range for PCH exceeded; please recompile with a command line option of '-Zm310' or greater
fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit
So I fixed them by increasing the memory heap size. No problem there.
My question is more about if this problem hides another one? Will I eventually have to give it more memory if I keep on adding library headers to the precomp.h
? Is this the way programmers handle it, or would there be a "cleaner" way to do it?
More info:
Try using the 64-bit platform toolset in Visual Studio. Doing this resolved the issue for us, and it's is one of Microsoft's recommendations for how to address the C1076 error. It's also mentioned in a blog post on precompiled header compilation issues.
To change the platform toolset, open the project's .vcxproj and add <PreferredToolArchitecture>x64</PreferredToolArchitecture>
to each configuration property group as per https://stackoverflow.com/a/46069460/478380 (which is for VS 2017 but applies to 2013).
The /Zm parameter does not change anything about how the code is interpreted, so it does not hide a problem in the code, other than the fact that the code requires a lot of memory to compile.
The switch only informs the compiler about the memory costs it should plan for during compilation. In VS 2013, the default precompiled header buffer size is 75 MB, which is value that a complex project can reasonably exceed. In such situations, you can use /Zm to increase the limit. Alternately, you could invest significant work into reducing the complexity of your include files.
In most cases, it is a much better use of developers' time to increase /Zm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With