'Virtual range for PCH exceeded' issue - after Visual Studio 2019 Upgrade to 16.7.6

mwallner 6 Reputation points
2020-11-12T13:01:58.473+00:00

After we've upgraded from VS2019 16.6 to VS2019 16.7.6, we're sometimes getting the infamous C3859 error when compiling our MSVC solutions.

We're using x64 msbuild from the command line.
/maxcpucount for MSBuild is fixed to '4'
/MP is passed, we're compiling on 8-core i7 machines.
The exact same source occasionally fails to compile with the errors

  • Compiler Error C3859 "virtual memory range for PCH exceeded"
  • System Code 1455 "The paging file is too small for this operation to complete."
  • Fatal error C1076 "compiler limit : internal heap limit reached"

The generated PCHs are up to 300MB in size. Passing the '/Zm' switch (with values up 1000) didn't make a difference.

We've had issues with this years ago, using VS2010 - back then setting '/Zm200' solved the problem for us (note the error codes back then explicitly told us to increase to '/Zm150' or higher).

'reducing the complexity and size of our PCH files' really is not what we want to do - as we're intentionally sacrificing on memory in order to speed up our builds.

I'm wondering if there is a way to figure out what the actual underlying problem is that generates these sporadic occuring errors - and most important: how to fix it .

see my original post at StackOverflow: https://stackoverflow.com/questions/64802010/virtual-range-for-pch-exceeded-issue-after-visual-studio-2019-upgrade-to-16

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,049 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,690 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
38,744 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,416 Reputation points
    2020-11-13T03:18:21.95+00:00

    Hi @mwallner ,

    From the document about /ZM, there is a recommended suggestion:

    If the compiler emits the C1076 error message, an accompanying C3859 message specifies the factor argument to use when you recompile by using the /Zm compiler option. This message is only significant when a precompiled header uses #pragma hdrstop. In other cases, it is a spurious error caused by Windows virtual memory pressure issues, and the recommendation to use the /Zm option should be ignored. Instead, consider reducing the number of parallel processes when using the /maxcpucount option to MSBUILD.EXE in conjunction with the /MP option to CL.EXE. For more information, see Precompiled Header (PCH) issues and recommendations.

    Hope it could help you.

    Best Regards,
    Dylan

    ---
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.