3

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 .

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
mwallner
  • 985
  • 11
  • 23
  • Have you tried contacting Microsoft? – Alan Birtles Nov 12 '20 at 10:25
  • There's a similar problem when using PCHs on GCC. The compiler crashes if the PCH size is greater than 128 MB (the default stack size for PCHs in the cc1plus.exe executable). – Arrow Nov 12 '20 at 10:41
  • @AlanBirtles - I wish I could say so - still struggling to find the right place to put in a issue report :-/ – mwallner Nov 12 '20 at 10:49
  • 1
    @LostArrow - thanks for the note, yet we didn't have any Issues with large PCHs on the previous version of VS (16.6) – mwallner Nov 12 '20 at 10:49
  • There's usually a smiley face button in visual studio, just click that and it'll guide you through creating a bug report – Alan Birtles Nov 12 '20 at 11:35
  • Looks like there is an open issue in the VS feedback forum: https://developercommunity.visualstudio.com/content/problem/615654/c3859-failed-to-create-virtual-memory-for-pch.html – Jakub Berezanski Nov 12 '20 at 12:46

2 Answers2

1

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.
Acherax
  • 11
  • 1
0

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.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • note we didn't need any 'workarounds' for this issue after upgrading VS2013 -> VS2015 -> VS2019 (16.6), it just worked. we've been doing 100+ builds/week for more than half a year with 16.6 and never saw this issue - it immediately appeared after upgrading from 16.6 to 16.7.6 and now happens in about 1 out of 5 builds. – mwallner Nov 13 '20 at 07:35
  • Using x64 msbuild, changing `maxcpucount ` to 2 or less, using `/Zm 1000` are the workarounds, did you use them all? I think you have used all of them. From another perspective, VS IDE itself does have some performance problems with that issue. – Mr Qian Nov 13 '20 at 08:09