/Zm
(Specify precompiled header memory allocation limit)
Determines the amount of memory that the compiler allocates to construct precompiled headers.
Syntax
/Zm
factor
Arguments
factor
A scaling factor percentage that determines the amount of memory that the compiler uses to construct precompiled headers.
The factor
argument is a percentage of the default size of a compiler-defined work buffer. The default value of factor
is 100 (percent), but you can specify larger or smaller amounts.
Remarks
In versions before Visual Studio 2015, the C++ compiler used several discrete heaps, and each had a finite limit. Currently, the compiler dynamically grows the heaps as necessary up to a total heap size limit, and allows the precompiled header to comprise multiple address ranges. Now, the /Zm
compiler option is rarely necessary.
If the compiler runs out of heap space and emits the C1060 error message when you use the /Zm
compiler option, you might have reserved too much memory. Consider removing the /Zm
option.
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's 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 together with the /MP
option to CL.EXE. For more information, see Precompiled Header (PCH) issues and recommendations.
The following table shows how the factor
argument affects the memory allocation limit. In the table, we assume the size of the default precompiled header buffer is 75 MB.
Value of factor |
Memory allocation limit |
---|---|
10 | 7.5 MB |
100 | 75 MB |
200 | 150 MB |
1000 | 750 MB |
2000 | 1500 MB |
Other ways to set the memory allocation limit
To set the /Zm
compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Command Line property page.
Enter the /Zm compiler option in the Additional Options box.
To set the /Zm
compiler option programmatically
- See AdditionalOptions.