|
1 | 1 | ---
|
2 |
| -description: "Learn more about: /Zm (Specify Precompiled Header Memory Allocation Limit)" |
3 |
| -title: "/Zm (Specify Precompiled Header Memory Allocation Limit)" |
4 |
| -ms.date: "03/08/2019" |
5 |
| -f1_keywords: ["/zm"] |
| 2 | +description: "Learn more about: /Zm (Specify precompiled header memory allocation limit)" |
| 3 | +title: "/Zm (Specify precompiled header memory allocation limit)" |
| 4 | +ms.date: 02/22/2022 |
| 5 | +f1_keywords: ["/Zm"] |
6 | 6 | helpviewer_keywords: ["PCH files, memory allocation limit", "Zm compiler option [C++]", "/Zm compiler option [C++]", "precompiled header files, memory allocation limit", "Specify Precompiled Header Memory Allocation Limit compiler option", "cl.exe compiler, memory allocation limit", ".pch files, memory allocation limit", "memory allocation, Memory Allocation Limit compiler option", "-Zm compiler option [C++]"]
|
7 | 7 | ms.assetid: 94c77d5e-6672-46a7-92e0-3f69e277727d
|
8 | 8 | ---
|
9 |
| -# /Zm (Specify Precompiled Header Memory Allocation Limit) |
| 9 | +# `/Zm` (Specify precompiled header memory allocation limit) |
10 | 10 |
|
11 | 11 | Determines the amount of memory that the compiler allocates to construct precompiled headers.
|
12 | 12 |
|
13 | 13 | ## Syntax
|
14 | 14 |
|
15 |
| -``` |
16 |
| -/Zmfactor |
17 |
| -``` |
| 15 | +> **`/Zm`***`factor`* |
18 | 16 |
|
19 | 17 | ## Arguments
|
20 | 18 |
|
21 |
| -*factor*<br/> |
22 |
| -A scaling factor that determines the amount of memory that the compiler uses to construct precompiled headers. |
| 19 | +*`factor`*<br/> |
| 20 | +A scaling factor percentage that determines the amount of memory that the compiler uses to construct precompiled headers. |
23 | 21 |
|
24 |
| -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. |
| 22 | +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. |
25 | 23 |
|
26 | 24 | ## Remarks
|
27 | 25 |
|
28 |
| -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. Consequently, the **/Zm** compiler option is rarely necessary. |
| 26 | +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. |
29 | 27 |
|
30 |
| -If the compiler runs out of heap space and emits the [C1060](../../error-messages/compiler-errors-1/fatal-error-c1060.md) error message when you use the **/Zm** compiler option, you might have reserved too much memory. Consider removing the **/Zm** option. |
| 28 | +If the compiler runs out of heap space and emits the [C1060](../../error-messages/compiler-errors-1/fatal-error-c1060.md) error message when you use the **`/Zm`** compiler option, you might have reserved too much memory. Consider removing the **`/Zm`** option. |
31 | 29 |
|
32 |
| -If the compiler emits the [C1076](../../error-messages/compiler-errors-1/fatal-error-c1076.md) error message, an accompanying [C3859](../../error-messages/compiler-errors-2/compiler-error-c3859.md) 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](https://devblogs.microsoft.com/cppblog/precompiled-header-pch-issues-and-recommendations/). |
| 30 | +If the compiler emits the [C1076](../../error-messages/compiler-errors-1/fatal-error-c1076.md) error message, an accompanying [C3859](../../error-messages/compiler-errors-2/compiler-error-c3859.md) 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](https://devblogs.microsoft.com/cppblog/precompiled-header-pch-issues-and-recommendations/). |
33 | 31 |
|
34 |
| -The following table shows how the *factor* argument affects the memory allocation limit if you assume the size of the default precompiled header buffer is 75 MB. |
| 32 | +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. |
35 | 33 |
|
36 |
| -|Value of *factor*|Memory allocation limit| |
37 |
| -|-----------------------|-----------------------------| |
38 |
| -|10|7.5 MB| |
39 |
| -|100|75 MB| |
40 |
| -|200|150 MB| |
41 |
| -|1000|750 MB| |
42 |
| -|2000|1500 MB| |
| 34 | +| Value of *`factor`* | Memory allocation limit | |
| 35 | +|--|--| |
| 36 | +| 10 | 7.5 MB | |
| 37 | +| 100 | 75 MB | |
| 38 | +| 200 | 150 MB | |
| 39 | +| 1000 | 750 MB | |
| 40 | +| 2000 | 1500 MB | |
43 | 41 |
|
44 |
| -## Other Ways to Set the Memory Allocation Limit |
| 42 | +## Other ways to set the memory allocation limit |
45 | 43 |
|
46 |
| -### To set the /Zm compiler option in the Visual Studio development environment |
| 44 | +### To set the `/Zm` compiler option in the Visual Studio development environment |
47 | 45 |
|
48 | 46 | 1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
|
49 | 47 |
|
50 | 48 | 1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
|
51 | 49 |
|
52 | 50 | 1. Enter the **/Zm** compiler option in the **Additional Options** box.
|
53 | 51 |
|
54 |
| -### To set the /Zm compiler option programmatically |
| 52 | +### To set the `/Zm` compiler option programmatically |
55 | 53 |
|
56 | 54 | - See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
|
57 | 55 |
|
58 | 56 | ## See also
|
59 | 57 |
|
60 |
| -[MSVC Compiler Options](compiler-options.md)<br/> |
61 |
| -[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md) |
| 58 | +[MSVC compiler options](compiler-options.md)<br/> |
| 59 | +[MSVC compiler command-line syntax](compiler-command-line-syntax.md) |
0 commit comments