I get this error message from time to time (not every time) I compile (EDIT: sorry, I didn’t make myself clear here: I actually meant «rebuild») my mixed-mode project. And Visual Studio tells me to «recompile with a command line option of ‘-Zm114’ or greater». In principle no problem, I just do as VS tells me.
But currently, there are two problems with this:
-
Why does it not occur every time I do a rebuild? If I understand correctly, the compiler ran out of memory while compiling my project. So if I do a rebuild, which cleans all prior work, shouldn’t it run out of memory the next time too, if I don’t change anything?
-
To be on the safe side, I already have specified a value of 120 for Zm (ie
Zm120
) in all configurations of this project. Why do I get an error message with this lower value? Or is the suggested value of 114 just a wild guess of VS?
asked Jul 20, 2016 at 11:17
derpirscherderpirscher
12.9k3 gold badges15 silver badges35 bronze badges
5
I know this is old but I ended up here so I might as well answer.
There is a great article about PCH problems here.
1) Why does it not occur every time I do a rebuild?
This is a bit complex to answer surely. Since it is not happening every time, it could be several issues. It is most likely due to memory allocation. From the article :
- Fragmentation of the virtual memory address range(s) required by the
PCH before CL.EXE is able to load it into memory.- Failure of the Windows OS under heavy loads to increase the pagefile size within a certain time threshold.
It could also be a Pagefile size problem (most likely on Virtual machines) but I believe you would have a message similar to this :
c1xx : error C3859: Failed to create virtual memory for PCH […Project.vcxproj] c1xx: note: the system returned code 1455: The paging file is too small for this operation to complete
2) Why do I get an error message with this lower value? (Zm114 instead of Zm120)
Make sure that the Zm120 modifications handle all the build configurations (Release|Debug) and Platform (x86|x64).
It could also help to set PreferredToolArchtecture to x64:
If you’re using MSBuild from the command line you can pass /p:PreferredToolArchtecture=x64 to MSBuild. If you’re building with MSBuild from within Visual Studio, you can edit your .vcxproj file to include a PropertyGroup containing this property.
This one is easily overlook, but those kind of problem also happen when the precompiled header is just too big. Doing a little cleanup might be a good idea as well.
answered May 16, 2018 at 8:08
ScottScott
3563 silver badges10 bronze badges
I was running into this compiling a large code base on a local VM. Tried upping the page file size etc and didn’t work. The only thing that worked in my case was to disable dynamic memory in the Hyper-V VM setting and give the VM more RAM, 8GB -> 16GB.
Apparently VS allocates it’s memory up-front so it only uses the initial value given to the VM and won’t trigger any dynamic memory changes.
answered Jan 30, 2020 at 19:22
GeordieGeordie
1,8141 gold badge23 silver badges30 bronze badges
Our builds were failing in our Jenkins CI pipeline due to PCH and memory issues.
Our problem was that WinRM had a low limit for the allowed shell memory.
After updating this, and setting it to unlimited, we are not getting any more memory related issues with builds.
winrm.cmd set winrm/config/winrs @{MaxMemoryPerShellMB="0"}
Some background:
- Our Windows builds are done in Amazon AWS AMIs
- WinRM is the remote shell that Jenkins uses to connect to the AMI
- We use packer to set up the AMIs
- The above command was added to the packer bootstrap file
- The above command comes from: Configure Maximum Powershell Memory in Windows Server
- More about the quota management: Quota Management for Remote Shells
answered Jan 13, 2021 at 11:45
CJCombrinkCJCombrink
3,6061 gold badge22 silver badges38 bronze badges
1
Just chiming in with what the solution ended up being for me. It seems that Visual Studio was trying to compile my program for multiple architectures, despite me thinking I had removed the profiles, there were a bunch of bogus entries in the configuration manager to build in x86 mode. These were useless to me since I want to build in x64 only. After removing those entries, the program compiled again and this error was gone. Hope it helps someone.
answered Aug 9, 2018 at 9:34
Yet another cause of this problem. I’m not crystal clear how the project got into this condition, but it was trying to use PCH files, had the «Precompiled Header File» option set to pch.h
, but the «Precompiled Header Output» option just below was empty.
Not really surprisingly, but Visual Studio got its nose very badly out of joint about that, in particular throwing numerous C3859
errors during the build.
Sorting out the project configuration to «Inherit» this value fixed it right up.
answered Oct 18, 2019 at 1:57
dgnuffdgnuff
3,0352 gold badges18 silver badges31 bronze badges
- Remove From My Forums
-
Question
-
Hi,
We have moved our VC++ projects to VS2019 and when tried to build the project we got the following errors after compiling some files…
3>c1xx: error C3859: Failed to create virtual memory for PCH
3>c1xx: note: PCH: Unable to get the requested block of memoryI have gone through the forums as mentioned by the ciompiler but still getting the same error
3>c1xx: note: please visit https://aka.ms/pch-help for more details
Can you please help in resolving these issues?
Thanks,
Mohan
-
Moved by
Tuesday, June 18, 2019 7:40 AM
-
Moved by
I know this is old but I ended up here so I might as well answer.
There is a great article about PCH problems here.
1) Why does it not occur every time I do a rebuild?
This is a bit complex to answer surely. Since it is not happening every time, it could be several issues. It is most likely due to memory allocation. From the article :
- Fragmentation of the virtual memory address range(s) required by the
PCH before CL.EXE is able to load it into memory.- Failure of the Windows OS under heavy loads to increase the pagefile size within a certain time threshold.
It could also be a Pagefile size problem (most likely on Virtual machines) but I believe you would have a message similar to this :
c1xx : error C3859: Failed to create virtual memory for PCH […Project.vcxproj] c1xx: note: the system returned code 1455: The paging file is too small for this operation to complete
2) Why do I get an error message with this lower value? (Zm114 instead of Zm120)
Make sure that the Zm120 modifications handle all the build configurations (Release|Debug) and Platform (x86|x64).
It could also help to set PreferredToolArchtecture to x64:
If you’re using MSBuild from the command line you can pass /p:PreferredToolArchtecture=x64 to MSBuild. If you’re building with MSBuild from within Visual Studio, you can edit your .vcxproj file to include a PropertyGroup containing this property.
This one is easily overlook, but those kind of problem also happen when the precompiled header is just too big. Doing a little cleanup might be a good idea as well.
I was running into this compiling a large code base on a local VM. Tried upping the page file size etc and didn’t work. The only thing that worked in my case was to disable dynamic memory in the Hyper-V VM setting and give the VM more RAM, 8GB -> 16GB.
Apparently VS allocates it’s memory up-front so it only uses the initial value given to the VM and won’t trigger any dynamic memory changes.
Tags:
C++
Compiler Errors
Precompiled Headers
Visual Studio 2015
Mixed Mode
Related
Comments
msftbot
bot
added
Needs-Triage
It’s a new issue that the core contributor team needs to triage at the next triage meeting
Needs-Tag-Fix
Doesn’t match tag requirements
labels
Jan 14, 2020
msftbot
bot
added
Needs-Attention
The core contributors need to come back around and look at this ASAP.
and removed
Needs-Author-Feedback
The original author of the issue/PR needs to come back and respond to something
labels
Jan 14, 2020
valentinbreiz
changed the title
Build errors : Failed to create virtual memory for PCH and others
Build errors : Failed to create virtual memory for PCH / Compiler is hout of heap space
Jan 15, 2020
valentinbreiz
changed the title
Build errors : Failed to create virtual memory for PCH / Compiler is hout of heap space
Build errors : Failed to create virtual memory for PCH / Compiler is out of heap space
Jan 15, 2020
- Forum
- Windows Programming
- PCH errors after c++20
PCH errors after c++20
Recently, c++20 came out and I updated one of my big projects to c++20, however I am running into some compilation errors that are beyond my understanding as of this moment.
The error(s) in question are:
C1076 compiler limit: internal heap limit reached
C3859 Failed to create virtual memory for PCH
I’ve been trying to mess around with the virtual memory allocation as a desperate attempt to fix it.
The only «fix» I’ve managed to get to so far is to just keep building after these errors are hit, and after a build or two, it successfully builds and runs without any issues.
Any ideas? Can also upload logs and the equivalent if required.
Thanks in advance.
EDITS/ADDITIONAL INFORMATION:
Using the inbuilt compiler in Visual Studio 2019 — ISO C++20 Standard
Last edited on
What’s your compiler? Currently the only compiler that is 100% C++20 compliant is Visual Studio 2019/2022.
Visual Studio 2019, using the built in compiler that comes with 2019 (ISO C++20 Standard)
M’ok, 2019 has some problems with C++20, you should set the C++ language standard to c++:latest instead C++20.
I’d recommend getting VS 2022, it works better than 2019. And it can use the C++20 language standard instead of latest.
Of course VS 2022 requires you are Windows x64. If you are 32-bit you are kinda stuck with VS 2019.
I have both 2019 and 2022 installed, Community editions, and I’ve found 2022 to be less twitchy than 2019, especially when using C++20 language features.
And consider not using precompiled headers if you can, they’ve been causing problems for a long time, since VS 6 that I’ve noticed. The very small amount of time saved using them is not worth the problems they can cause.
When I start a new project/solution I use the Windows Desktop Wizard project template so I can specify what the application type is — Console, Desktop (WinAPI), Dynamic Library or Static Library — and select the «Empty Project» check box. No files are added to the project so I can add what files I need/want. Now I don’t have to deal with precompiled headers. Less problems that way.
FYI, a minor update to 2019 and 2022 was released yesterday. You could install the update and see if that fixes your problems, though I doubt it given what the details of the update are.
PCH refers to Pre Compiled Header.
Have you tried a complete Rebuild Solution as opposed as just a Rebuid?
What’s the setting for PCH in properties? I don’t use them as this kept causing build issues.
If you consume C++20 modules, stdlib or custom modules, using precompiled headers can on occasion really make VS go loopy if you don’t rebuild the entire project/solution.
Another reason why I don’t let VS use the danged «feature.»
The personal project I have is kind of a «rip-off» from work as I’ve been assigned the memory management of our projects, and considering the size of the codebase, solutions, etc, PCH is a solid solution to spare hours, maybe even days to compile for ourselves.
Apart from trying to see the positives in it, it’s what’s been used for a long time, and deconstructing the PCH might not be very desirable.
I make sure that VS is up to date, and I was hoping that updating it would solve it, but alas, it didn’t.
I have tried a couple things;
— Clean solution -> Build Solution
— Clean Solution -> Rebuild Solution
— Fresh «install» of the project through version control -> Build
Well, I’ve set the Precompiled Header to «Use (/Yu)», the name for the header file that is the PCH, and set a PCH Output File as well.
Yeah it seems like PCH makes things a bit unstable.
I’m not too well versed in it, but it really just seems like there’s not enough space for the PCH to do it’s thing, as building it 2-3 times in a row just removes the issue entirely at the last build and runs as it should.
So the size of a PCH I can understand can get a bit big, however the bit where it «fails to allocate virtual memory», I fail to see the connection.
Thanks for your advice and help so far.
Just turn off using PCH.
That is an option, however not a highly desirable one.
The difference in compilation time would be enormous, might have to if there is no solution to this, but until hope is lost, I wish to attempt.
If I do find anything, I’ll post it here.
The difference in compilation time would be enormous,
Perhaps not as much as you might think. VS now does incremental compilation of only those functions which have changed. If they haven’t changed then they are copied from the previous compilation.
markofn1 wrote: |
---|
The difference in compilation time would be enormous |
Are you sure about that? Have you actually done tests? The MSVC++ compiler is a lot more efficient than it used to be. The underlying compiler in 2022 is better, marginally, than 2019’s. 2019 is still speedy when doing incremental builds.
Right now using precompiled headers is a huge time waste since you can’t get your project(s) to compile.
Not using PCH will take some extra time the first compilation, especially if done as a full rebuild. Builds after that should be speedier since they will be incremental builds.
I’ll give it a go and not use PCH, cause truth be told I have not compared the compilation speed of the two alternatives.
There is only but one fix I have found for this error, and that is to simply upgrade to VS 2022 instead of VS 2019.
Thank you all kindly for your help, suggestions and explanations.
If you can use c++ modules, there should be a dramatic improvement on compilation times compared to normal compilation methods, especially if the project is large.
George P has done it on windows — he knows all about it :+)
Edit: I am sure George made some posts about it, you could search for them.
Last edited on
Any time I create a new project in VS I always choose to not use precompiled headers, whether I use modules or not. Have been doing that for years, so C++20 introducing modules hasn’t been a big change in compilation speeds for me.
One thing to note about using modules, the first time when using a new import the compile time increases slightly as VS compiles the referenced module. Every compile afterwards is speedier because the module is already compiled.
Now, about user created modules the same holds true, as long as the module isn’t modified. First time/make a change takes a wee bit longer.
Forget using the travesty of the MS workaround of std.core. Importing that is as troublesome as precompiled headers in my experience. Just change the C++ stdlib includes to import and you’re good to go.
My projects are usually smallish so any promised advantage modules were supposed to have about being speedier than includes is kinda hard to document. The lengthiest compile time for a single project I can remember was about 45 seconds. Compile times using modules seems to be marginally quicker.
Converting a pre-existing include headers project is either:
1. as simple as changing a couple of keywords in the file. If it’s a header change the file extension. If it’s a source file that accompanies the header change how it is compiles to an internal partition.
2. If the files are code interlocked, one needs another to work, converting to modules can be more time consuming vs. the benefits of using modules. At least that has been my limited experience of trying to convert a pre-modules project to modules.
did you try the derp move of deleting the pch files and letting it rebuild them from scratch? takes a long time, but if they are corrupted, its over. I work on a big project as well and when those go bad (they do in 2019, frequently enough) or the PDB goes bad there is nothing for it but sitting out a longer compile.
All the way back to visual studio 5.0 (I started on 1.0, but that was another story, 5.0 is where I started working with it daily and in depth) the rule of the day was to turn PCH off right away on new projects. It has never worked right, and this is going on 25+ years of having it. Edit-continue PDB is also high risk of failing. Good ideas that sorta work but never quite got a full debugging.
you can try to get it working. One of the failure points is when the files get too big, though. Breaking the code into many small projects that work together to produce a bigger project is a big help.
Last edited on
Topic archived. No new replies allowed.
Я получаю это сообщение об ошибке время от времени (не каждый раз), когда я компилирую (РЕДАКТИРОВАТЬ: извините, я не прояснил здесь: я на самом деле имел в виду «перестроить») мой проект смешанного режима. И Visual Studio говорит мне «перекомпилировать с параметром командной строки« -Zm114 »или выше». В принципе нет проблем, я просто делаю, как говорит мне VS.
Но в настоящее время есть две проблемы с этим:
-
Почему это не происходит каждый раз Я делаю перестройку? Если я правильно понимаю, компилятору не хватило памяти при компиляции моего проекта. Так что, если я сделаю перестройку, которая очищает всю предыдущую работу, разве в следующий раз ей не хватит памяти, если я ничего не изменю?
-
Чтобы быть в безопасности, я уже указал значение 120 для Zm (т.е.
Zm120
) во всех конфигурациях этого проекта. Почему я получаю сообщение об ошибке с этим более низким значением? Или предложенное значение 114 просто дикое предположение о VS?
4
Решение
Я знаю, что это старо, но я оказался здесь, так что я мог бы ответить.
Есть отличная статья о проблемах PCH Вот.
1) Почему это не происходит каждый раз, когда я делаю перестройку?
Это немного сложно, чтобы ответить наверняка. Так как это происходит не каждый раз, это может быть несколько проблем. Скорее всего, это связано с распределением памяти. Из статьи:
- фрагментация диапазонов адресов виртуальной памяти, требуемых
PCH перед CL.EXE может загрузить его в память.- Отказ ОС Windows при больших нагрузках увеличить размер файла подкачки за определенный промежуток времени.
Это также может быть проблема размера файла подкачки (скорее всего, на виртуальных машинах), но я думаю, что у вас будет сообщение, подобное этому:
c1xx: ошибка C3859: не удалось создать виртуальную память для PCH [… Project.vcxproj] c1xx: примечание: система вернула код 1455: файл подкачки слишком мал для выполнения этой операции
2) Почему я получаю сообщение об ошибке с этим более низким значением? (Zm114 вместо Zm120)
Убедитесь, что модификации Zm120 обрабатывают все конфигурации сборки (Release | Debug) и Platform (x86 | x64).
Это также может помочь установить PreferredToolArchtecture в x64:
Если вы используете MSBuild из командной строки, вы можете передать / p: PreferredToolArchtecture = x64 в MSBuild. Если вы строите с помощью MSBuild из Visual Studio, вы можете отредактировать файл .vcxproj, включив в него группу PropertyGroup, содержащую это свойство.
Эту проблему легко упустить из виду, но подобные проблемы возникают и тогда, когда предварительно скомпилированный заголовок слишком велик. Небольшая уборка также может быть хорошей идеей.
2
Другие решения
Просто согласиться с тем, что решение оказалось для меня. Кажется, что Visual Studio пыталась скомпилировать мою программу для нескольких архитектур, несмотря на то, что я думал, что удалил профили, в диспетчере конфигурации была куча поддельных записей для сборки в режиме x86. Это было бесполезно для меня, так как я хочу встроить только в x64. После удаления этих записей программа снова скомпилировалась, и эта ошибка исчезла. Надеюсь, это поможет кому-то.
0
I am new to unreal so ELI5. This problem started early yesterday and I have been trying to fix it since then.
I ran my unreal engine project through visual studio (using F5) yesterday, and visual studio gave me this error:
Building FPSGameEditor...
Using Visual Studio 2019 14.26.28805 toolchain (C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.26.28801) and Windows 10.0.18362.0 SDK (C:Program Files (x86)Windows Kits10).
[Upgrade]
[Upgrade] Using backward-compatible build settings. The latest version of UE4 sets the following values by default, which may require code changes:
[Upgrade] bLegacyPublicIncludePaths = false => Omits subfolders from public include paths to reduce compiler command line length. (Previously: true).
[Upgrade] ShadowVariableWarningLevel = WarningLevel.Error => Treats shadowed variable warnings as errors. (Previously: WarningLevel.Warning).
[Upgrade] PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs => Set in build.cs files to enables IWYU-style PCH model. See https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/index.html. (Previously: PCHUsageMode.UseSharedPCHs).
[Upgrade] Suppress this message by setting 'DefaultBuildSettings = BuildSettingsVersion.V2;' in FPSGameEditor.Target.cs, and explicitly overriding settings that differ from the new defaults.
[Upgrade]
Building 8 actions with 8 processes...
[1/8] FPSProjectile.cpp
c1xx : error C3859: Failed to create virtual memory for PCH
c1xx: note: the system returned code 1455: The paging file is too small for this operation to complete.
c1xx: note: please visit https://aka.ms/pch-help for more details
c1xx : fatal error C1076: compiler limit: internal heap limit reached
[2/8] FPSCharacter.cpp
c1xx : error C3859: Failed to create virtual memory for PCH
c1xx: note: the system returned code 1455: The paging file is too small for this operation to complete.
c1xx: note: please visit https://aka.ms/pch-help for more details
c1xx : fatal error C1076: compiler limit: internal heap limit reached
[3/8] FPSGame.init.gen.cpp
[4/8] FPSObjectiveActor.cpp
[5/8] FPSCharacter.gen.cpp
C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVCv160Microsoft.MakeFile.Targets(46,5): error MSB3073: The command "chcp 65001 >NUL && "A:Epic GamesEpic GamesUE_4.25EngineBuildBatchFilesBuild.bat" FPSGameEditor Win64 Development -Project="C:UsersDavidDesktopHiddenUnrealStealthGameFPSGameFPSGame.uproject" -WaitMutex -FromMsBuild" exited with code 6.
It only gave me this error once, then I restarted and tried again.
Now, anytime I try to run the code through visual studio, It gives me this:
Displayed when pressing F5
I have completely reinstalled both ue4 and visual studio, and any solutions i found involving the ‘linker’ aren’t helpful, because I don’t have the linker tool for some reason.
If I open my unreal project, the game still runs fine as it was. However, I cant add any new code because VS wont compile anymore. Any help is appreciated.