Skip to content

Commit 6c2e23c

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#2299 from MicrosoftDocs/master637298271429493867
Fix git push error for protected CLA branch
2 parents fcf8a28 + 963696e commit 6c2e23c

File tree

4 files changed

+82
-66
lines changed

4 files changed

+82
-66
lines changed

docs/build/reference/heap.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
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 options](linker-options.md)

docs/cpp/com-ptr-t-extractors.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
22
title: "_com_ptr_t Extractors"
3-
ms.date: "11/04/2016"
3+
description: "Describes the extraction operators for the _com_ptr_t class."
4+
ms.date: 07/07/2020
45
f1_keywords: ["_com_ptr_t::operatorInterface&", "_com_ptr_t::operatorbool", "_com_ptr_t::operator->", "_com_ptr_t::operator*"]
56
helpviewer_keywords: ["operator Interface& [C++]", "* operator [C++], with specific objects", "operator& [C++]", "operator* [C++]", "-> operator [C++], with specific objects", "& operator [C++], with specific objects", "operator Interface* [C++]", "operator * [C++]", "operator->", "operator bool", "extractors, _com_ptr_t class", "extractors [C++]"]
67
ms.assetid: 194b9e0e-123c-49ff-a187-0a7fcd68145a
78
---
8-
# _com_ptr_t Extractors
9+
# `_com_ptr_t` Extractors
910

10-
**Microsoft Specific**
11+
**Microsoft-specific**
1112

1213
Extract the encapsulated COM interface pointer.
1314

1415
## Syntax
1516

16-
```
17+
```c++
1718
operator Interface*( ) const throw( );
1819
operator Interface&( ) const;
1920
Interface& operator*( ) const;
@@ -24,20 +25,21 @@ operator bool( ) const throw( );
2425
2526
## Remarks
2627
27-
- **operator Interface**<strong>\*</strong> Returns the encapsulated interface pointer, which may be NULL.
28+
- **`operator Interface*`** Returns the encapsulated interface pointer, which may be NULL.
2829
29-
- **operator Interface&** Returns a reference to the encapsulated interface pointer, and issues an error if the pointer is NULL.
30+
- **`operator Interface&`** Returns a reference to the encapsulated interface pointer, and issues an error if the pointer is NULL.
3031
31-
- **operator**<strong>\*</strong> Allows a smart pointer object to act as though it were the actual encapsulated interface when dereferenced.
32+
- **`operator*`** Allows a smart pointer object to act as though it were the actual encapsulated interface when dereferenced.
3233
33-
- **operator->** Allows a smart pointer object to act as though it were the actual encapsulated interface when dereferenced.
34+
- **`operator->`** Allows a smart pointer object to act as though it were the actual encapsulated interface when dereferenced.
3435
35-
- **operator&** Releases any encapsulated interface pointer, replacing it with NULL, and returns the address of the encapsulated pointer. This allows the smart pointer to be passed by address to a function that has an *out* parameter through which it returns an interface pointer.
36+
- **`operator&`** Releases any encapsulated interface pointer, replacing it with NULL, and returns the address of the encapsulated pointer. This operator allows you to pass the smart pointer by address to a function that has an *out* parameter through which it returns an interface pointer.
3637
37-
- **operator bool** Allows a smart pointer object to be used in a conditional expression. This operator returns TRUE if the pointer is not NULL.
38+
- **`operator bool`** Allows a smart pointer object to be used in a conditional expression. This operator returns TRUE if the pointer isn't NULL.
3839
39-
**END Microsoft Specific**
40+
> [!NOTE]
41+
> Because **`operator bool`** is not declared as **`explicit`**, `_com_ptr_t` is implicitly convertible to **`bool`**, which is convertible to any scalar type. This can have unexpected consequences in your code. Enable [Compiler Warning (level 4) C4800](../error-messages/compiler-warnings/compiler-warning-level-3-c4800.md) to prevent unintentional use of this conversion.
4042
4143
## See also
4244
43-
[_com_ptr_t Class](../cpp/com-ptr-t-class.md)
45+
[_com_ptr_t class](../cpp/com-ptr-t-class.md)

docs/cpp/new-and-delete-operators.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
---
2-
title: "new and delete Operators"
3-
ms.date: "11/19/2019"
2+
title: "new and delete operators"
3+
description: "The C++ language new and delete operators allow control over allocation."
4+
ms.date: 07/07/2020
45
helpviewer_keywords: ["new keyword [C++]", "delete keyword [C++]"]
5-
ms.assetid: fa721b9e-0374-4f04-bb87-032ea775bcc8
66
---
7-
# new and delete operators
7+
# `new` and `delete` operators
88

9-
C++ supports dynamic allocation and deallocation of objects using the [new](new-operator-cpp.md) and [delete](delete-operator-cpp.md) operators. These operators allocate memory for objects from a pool called the free store. The **new** operator calls the special function [operator new](new-operator-cpp.md), and the **delete** operator calls the special function [operator delete](delete-operator-cpp.md).
9+
C++ supports dynamic allocation and deallocation of objects using the [`new`](new-operator-cpp.md) and [`delete`](delete-operator-cpp.md) operators. These operators allocate memory for objects from a pool called the free store. The **`new`** operator calls the special function [`operator new`](new-operator-cpp.md), and the **`delete`** operator calls the special function [`operator delete`](delete-operator-cpp.md).
1010

11-
The **new** function in the C++ Standard Library supports the behavior specified in the C++ standard, which is to throw a std::bad_alloc exception if the memory allocation fails. If you still want the non-throwing version of **new**, link your program with nothrownew.obj. However, when you link with nothrownew.obj, the default **operator new** in the C++ Standard Library no longer functions.
11+
The **`new`** function in the C++ Standard Library supports the behavior specified in the C++ standard, which is to throw a `std::bad_alloc` exception if the memory allocation fails. If you still want the non-throwing version of **`new`**, link your program with *`nothrownew.obj`*. However, when you link with *`nothrownew.obj`*, the default **`operator new`** in the C++ Standard Library no longer functions.
1212

13-
For a list of the library files that comprise the C Runtime Library and the C++ Standard Library, see [CRT Library Features](../c-runtime-library/crt-library-features.md).
13+
For a list of the library files in the C Runtime Library and the C++ Standard Library, see [CRT Library Features](../c-runtime-library/crt-library-features.md).
1414

15-
## <a id="new_operator"> </a> The new operator
15+
## <a id="new_operator"> </a> The `new` operator
1616

17-
When a statement such as the following is encountered in a program, it translates into a call to the function **operator new**:
17+
The compiler translates a statement such as this one into a call to the function **`operator new`**:
1818

1919
```cpp
2020
char *pch = new char[BUFFER_SIZE];
2121
```
2222

23-
If the request is for zero bytes of storage, **operator new** returns a pointer to a distinct object (that is, repeated calls to **operator new** return different pointers). If there is insufficient memory for the allocation request, **operator new** throws a `std::bad_alloc` exception, or returns **nullptr** if you have linked in non-throwing **operator new** support.
23+
If the request is for zero bytes of storage, **`operator new`** returns a pointer to a distinct object. That is, repeated calls to **`operator new`** return different pointers. If there's insufficient memory for the allocation request, **`operator new`** throws a `std::bad_alloc` exception. Or, it returns **`nullptr`** if you've linked in non-throwing **`operator new`** support.
2424

25-
You can write a routine that attempts to free memory and retry the allocation; see [_set_new_handler](../c-runtime-library/reference/set-new-handler.md) for more information. For more details on the recovery scheme, see the Handling insufficient memory section of this topic.
25+
You can write a routine that attempts to free memory and retry the allocation. For more information, see [`_set_new_handler`](../c-runtime-library/reference/set-new-handler.md). For details on the recovery scheme, see the [Handling insufficient memory](#handling-insufficient-memory) section.
2626

27-
The two scopes for **operator new** functions are described in the following table.
27+
The two scopes for **`operator new`** functions are described in the following table.
2828

29-
### Scope for operator new functions
29+
### Scope for `operator new` functions
3030

31-
|Operator|Scope|
32-
|--------------|-----------|
33-
|**::operator new**|Global|
34-
|*class-name* **::operator new**|Class|
31+
| Operator | Scope |
32+
|--|--|
33+
| **`::operator new`** | Global |
34+
| *class-name* **`::operator new`** | Class |
3535

36-
The first argument to **operator new** must be of type `size_t` (a type defined in \<stddef.h>), and the return type is always **void** <strong>\*</strong>.
36+
The first argument to **`operator new`** must be of type `size_t`, defined in \<stddef.h>, and the return type is always **`void*`**.
3737

38-
The global **operator new** function is called when the **new** operator is used to allocate objects of built-in types, objects of class type that do not contain user-defined **operator new** functions, and arrays of any type. When the **new** operator is used to allocate objects of a class type where an **operator new** is defined, that class's **operator new** is called.
38+
The global **`operator new`** function is called when the **`new`** operator is used to allocate objects of built-in types, objects of class type that don't contain user-defined **`operator new`** functions, and arrays of any type. When the **`new`** operator is used to allocate objects of a class type where an **`operator new`** is defined, that class's **`operator new`** is called.
3939

40-
An **operator new** function defined for a class is a static member function (which cannot, therefore, be virtual) that hides the global **operator new** function for objects of that class type. Consider the case where **new** is used to allocate and set memory to a given value:
40+
An **`operator new`** function defined for a class is a static member function (which can't be virtual) that hides the global **`operator new`** function for objects of that class type. Consider the case where **`new`** is used to allocate and set memory to a given value:
4141

4242
```cpp
4343
#include <malloc.h>
@@ -66,13 +66,13 @@ int main()
6666
}
6767
```
6868

69-
The argument supplied in parentheses to **new** is passed to `Blanks::operator new` as the `chInit` argument. However, the global **operator new** function is hidden, causing code such as the following to generate an error:
69+
The argument supplied in parentheses to **`new`** is passed to `Blanks::operator new` as the `chInit` argument. However, the global **`operator new`** function is hidden, causing code such as the following to generate an error:
7070

7171
```cpp
7272
Blanks *SomeBlanks = new Blanks;
7373
```
7474

75-
The compiler supports member array **new** and **delete** operators in a class declaration. For example:
75+
The compiler supports member array **`new`** and **`delete`** operators in a class declaration. For example:
7676

7777
```cpp
7878
class MyClass
@@ -111,28 +111,28 @@ int main() {
111111
}
112112
```
113113
114-
There is another way to handle failed memory allocation requests. Write a custom recovery routine to handle such a failure, then register your function by calling the [_set_new_handler](../c-runtime-library/reference/set-new-handler.md) run-time function.
114+
There's another way to handle failed memory allocation requests. Write a custom recovery routine to handle such a failure, then register your function by calling the [`_set_new_handler`](../c-runtime-library/reference/set-new-handler.md) run-time function.
115115
116-
## <a id="delete_operator"> </a> The delete operator
116+
## <a id="delete_operator"> </a> The `delete` operator
117117
118-
Memory that is dynamically allocated using the **new** operator can be freed using the **delete** operator. The delete operator calls the **operator delete** function, which frees memory back to the available pool. Using the **delete** operator also causes the class destructor (if there is one) to be called.
118+
Memory that is dynamically allocated using the **`new`** operator can be freed using the **`delete`** operator. The delete operator calls the **`operator delete`** function, which frees memory back to the available pool. Using the **`delete`** operator also causes the class destructor (if one exists) to be called.
119119
120-
There are global and class-scoped **operator delete** functions. Only one **operator delete** function can be defined for a given class; if defined, it hides the global **operator delete** function. The global **operator delete** function is always called for arrays of any type.
120+
There are global and class-scoped **`operator delete`** functions. Only one **`operator delete`** function can be defined for a given class; if defined, it hides the global **`operator delete`** function. The global **`operator delete`** function is always called for arrays of any type.
121121
122-
The global **operator delete** function. Two forms exist for the global **operator delete** and class-member **operator delete** functions:
122+
The global **`operator delete`** function. Two forms exist for the global **`operator delete`** and class-member **`operator delete`** functions:
123123
124124
```cpp
125125
void operator delete( void * );
126126
void operator delete( void *, size_t );
127127
```
128128

129-
Only one of the preceding two forms can be present for a given class. The first form takes a single argument of type `void *`, which contains a pointer to the object to deallocate. The second formsized deallocationtakes two arguments, the first of which is a pointer to the memory block to deallocate and the second of which is the number of bytes to deallocate. The return type of both forms is **void** (**operator delete** cannot return a value).
129+
Only one of the preceding two forms can be present for a given class. The first form takes a single argument of type **`void *`**, which contains a pointer to the object to deallocate. The second form, sized deallocation, takes two arguments: the first is a pointer to the memory block to deallocate, and the second is the number of bytes to deallocate. The return type of both forms is **`void`** (**`operator delete`** can't return a value).
130130

131-
The intent of the second form is to speed up searching for the correct size category of the object to be deleted, which is often not stored near the allocation itself and likely uncached. The second form is useful when an **operator delete** function from a base class is used to delete an object of a derived class.
131+
The intent of the second form is to speed up searching for the correct size category of the object to delete. This information often isn't stored near the allocation itself, and is likely uncached. The second form is useful when an **`operator delete`** function from a base class is used to delete an object of a derived class.
132132

133-
The **operator delete** function is static; therefore, it cannot be virtual. The **operator delete** function obeys access control, as described in [Member-Access Control](member-access-control-cpp.md).
133+
The **`operator delete`** function is static, so it can't be virtual. The **`operator delete`** function obeys access control, as described in [Member-Access Control](member-access-control-cpp.md).
134134

135-
The following example shows user-defined **operator new** and **operator delete** functions designed to log allocations and deallocations of memory:
135+
The following example shows user-defined **`operator new`** and **`operator delete`** functions designed to log allocations and deallocations of memory:
136136

137137
```cpp
138138
#include <iostream>
@@ -180,9 +180,9 @@ int main( int argc, char *argv[] ) {
180180
}
181181
```
182182
183-
The preceding code can be used to detect "memory leakage"that is, memory that is allocated on the free store but never freed. To perform this detection, the global **new** and **delete** operators are redefined to count allocation and deallocation of memory.
183+
The preceding code can be used to detect "memory leakage", that is, memory that's allocated on the free store but never freed. To detect leaks, the global **`new`** and **`delete`** operators are redefined to count allocation and deallocation of memory.
184184
185-
The compiler supports member array **new** and **delete** operators in a class declaration. For example:
185+
The compiler supports member array **`new`** and **`delete`** operators in a class declaration. For example:
186186
187187
```cpp
188188
// spec1_the_operator_delete_function2.cpp

0 commit comments

Comments
 (0)