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

Viewed 1127

This might be related to 38479787/c3859-virtual-memory-range-for-pch-exceeded.

A good read on PCH issues and recommendations can be found here.

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"s

sample compilation output:

  1342>c1xx : error C3859: Fehler beim Erstellen des virtuellen Speichers für PCH. [C:\REDACTED\REDACTED.vcxproj] 
    c1xx : message : Das System hat den Code 1455 zurückgegeben: Die Auslagerungsdatei ist zu klein, um diesen Vorgang durchzuführen. [C:\REDACTED\REDACTED.vcxproj] 
    c1xx : message : Weitere Informationen finden Sie unter https://aka.ms/pch-help. [C:\REDACTED\REDACTED.vcxproj] 
  1342>c1xx : fatal error C1076: Compilerlimit: Interne Heapgrenze erreicht. [C:\REDACTED\REDACTED.vcxproj]   
  1342>c1xx : fatal error C1076: Compilerlimit: Interne Heapgrenze erreicht. [C:\REDACTED\REDACTED.vcxproj]  

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 .

2 Answers

Actually, it is quite a headache issue for a couple of years. And the workaround which you found is the current solution and does help build your project successfully before VS2019 16.7 version. And upgrading VS to 16.7, the issue still sometimes happens with all the workarounds you have used. This does have a certain relationship with the VS IDE version and your project. This is a problem caused by two aspects.

Since you don’t want to change the PCH file, I have reported the issue on our DC Forum.

You can vote it and add any comments if I did not describe the issue in detail so that it will get more Microsoft's attention.

=======================================

If you are using VS Professional or Enterprise version and willing to accept the risk of reinstalling the previous version of VS, you can try this. And if you do not want it, you can just ignore it.

Refer to this document and uninstall the current VS version and install the related 16.6 version from that link.

Besides, you could share a minimal, reproducible sample with us if you like.

I am using a virtual machine (VPS), and the final solution for me was to increase my virtual memory pagefile size. It may be that it was only efficient due to the NVMe SSD drive, but it may work well enough for whoever is reading this, regardless.

(Credit for this guide: [MSFT]Ulzii Luvsanbat)

  1. Open the Control Panel
  2. Select System and Security
  3. Select System
  4. In the Advanced tab of the System Properties dialog, select the Performance “Settings” button
  5. Select the Virtual Memory “Change” button on the Advanced tab
  6. Turn off “Automatically manage paging file size for all drives” and set the Custom size. Note that you should set both the “initial size” and “maximum size” to the same value, and you should set them to be large enough to avoid the OS exhausting the page file limit.
Related