Skip to content

Commit 1d7ccad

Browse files
author
Colin Robertson
committed
Address /HEAP issue 2267
1 parent 2bc347b commit 1d7ccad

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

docs/build/reference/heap.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
---
22
title: "/HEAP"
3-
ms.date: "11/04/2016"
3+
description: "The MSVC linker or EDITBIN /HEAP option sets the total heap size, and optionally the size of additional heap blocks."
4+
ms.date: 07/07/2020
45
f1_keywords: ["/heap"]
56
helpviewer_keywords: ["heap allocation, setting heap size", "HEAP editbin option", "-HEAP editbin option", "/HEAP editbin option"]
67
ms.assetid: 6ce759b5-75b7-44ff-a5fd-3a83a0ba9a48
78
---
8-
# /HEAP
9+
# `/HEAP`
910

1011
Sets the size of the heap in bytes. This option only applies to executable files.
1112

12-
```
13+
## Syntax
1314

14-
/HEAP:
15-
reserve[,commit]
16-
```
15+
> **`/HEAP:`**_`reserve`_\[**`,`**_`commit`_]
1716
1817
## Remarks
1918

20-
The `reserve` argument specifies the total initial heap allocation in virtual memory. By default, the heap size is 1 MB. [EDITBIN Reference](editbin-reference.md) rounds up the specified value to the nearest multiple of 4 bytes.
19+
The *`reserve`* argument specifies the total initial heap allocation in virtual memory. The **`/HEAP`** linker or [EDITBIN](editbin-reference.md) option rounds up the specified value to the nearest multiple of 4 bytes. By default, the heap size is 1 MB.
2120

22-
The optional `commit` argument is subject to interpretation by the operating system. On a Windows operating system, it specifies the initial amount of physical memory to allocate, and the amount of additional memory to allocate when the heap must be expanded. Committed virtual memory causes space to be reserved in the paging file. A higher `commit` value allows the system to allocate memory less often when the app needs more heap space but increases the memory requirements and possibly the app startup duration. The `commit` value must be less than or equal to the `reserve` value.
21+
The optional *`commit`* argument is subject to interpretation by the operating system. On a Windows operating system, it specifies the initial amount of physical memory to allocate. It also specifies how much more memory to allocate when the heap is expanded. Committed virtual memory causes space to be reserved in the paging file. A higher *`commit`* value allows the system to allocate memory less often when the app needs more heap space but increases the memory requirements and possibly the app startup duration. The *`commit`* value must be less than or equal to the *`reserve`* value. The default value is 4 KB.
2322

24-
Specify the `reserve` and `commit` values in decimal or C-language hexadecimal or octal notation. For example, a value of 1 MB can be specified as 1048576 in decimal, or as 0x100000 in hexadecimal, or as 04000000 in octal.
23+
Specify the *`reserve`* and *`commit`* values in decimal, C-language hexadecimal, or octal notation. For example, a value of 1 MB can be specified as 1048576 in decimal, or as 0x100000 in hexadecimal, or as 04000000 in octal. The default values are equivalent to the option **`/HEAP:1048576,4096`**.
24+
25+
### Example
26+
27+
This example link command creates an executable *main.exe* that has heap reserve of 2 MB. The initial heap and later heap expansions come in blocks of 64 KB:
28+
29+
**`link /heap:0x200000,0x10000 main.obj`**
30+
31+
### To set this linker option in Visual Studio
32+
33+
1. Open the project **Property Pages** dialog box. For more information, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
34+
35+
1. Select the **Configuration Properties** > **Linker** > **System** property page.
36+
37+
1. Set the **Heap Reserve Size** and **Heap Commit Size** properties, then choose **OK** or **Apply** to save your changes.
2538

2639
## See also
2740

28-
[EDITBIN Options](editbin-options.md)
41+
[EDITBIN options](editbin-options.md)\
42+
[MSVC linker reference](linking.md)\
43+
[MSVC linker options](linker-options.md)

0 commit comments

Comments
 (0)