|
303 | 303 | <format type="text/markdown"><![CDATA[
|
304 | 304 |
|
305 | 305 | ## Remarks
|
| 306 | +> [!IMPORTANT] |
| 307 | +> This native memory allocator is a legacy API that should be used exclusively when called for by specific Win32 APIs on the Windows platform. On non-Windows platforms, the <xref:System.Runtime.InteropServices.NativeMemory> class should be used to allocate native memory. |
| 308 | + |
306 | 309 | <xref:System.Runtime.InteropServices.Marshal.AllocHGlobal%2A> is one of two memory allocation methods in the <xref:System.Runtime.InteropServices.Marshal> class. (<xref:System.Runtime.InteropServices.Marshal.AllocCoTaskMem%2A?displayProperty=nameWithType> is the other.) This method exposes the Win32 [LocalAlloc](https://go.microsoft.com/fwlink/?LinkId=148628) function from Kernel32.dll.
|
307 | 310 |
|
308 | 311 | When <xref:System.Runtime.InteropServices.Marshal.AllocHGlobal%2A> calls `LocalAlloc`, it passes a `LMEM_FIXED` flag, which causes the allocated memory to be locked in place. Also, the allocated memory is not zero-filled.
|
|
383 | 386 | <format type="text/markdown"><![CDATA[
|
384 | 387 |
|
385 | 388 | ## Remarks
|
| 389 | +> [!IMPORTANT] |
| 390 | +> This native memory allocator is a legacy API that should be used exclusively when called for by specific Win32 APIs on the Windows platform. On non-Windows platforms, the <xref:System.Runtime.InteropServices.NativeMemory> class should be used to allocate native memory. |
| 391 | + |
386 | 392 | <xref:System.Runtime.InteropServices.Marshal.AllocHGlobal%2A> is one of two memory allocation methods in the <xref:System.Runtime.InteropServices.Marshal> class. (<xref:System.Runtime.InteropServices.Marshal.AllocCoTaskMem%2A?displayProperty=nameWithType> is the other.) This method exposes the Win32 [LocalAlloc](https://go.microsoft.com/fwlink/?LinkID=148628) function from Kernel32.dll.
|
387 | 393 |
|
388 | 394 | When <xref:System.Runtime.InteropServices.Marshal.AllocHGlobal%2A> calls `LocalAlloc`, it passes a `LMEM_FIXED` flag, which causes the allocated memory to be locked in place. Also, the allocated memory is not zero-filled.
|
|
2656 | 2662 | <format type="text/markdown"><![CDATA[
|
2657 | 2663 |
|
2658 | 2664 | ## Remarks
|
| 2665 | +> [!IMPORTANT] |
| 2666 | +> This native memory allocator is a legacy API that should be used exclusively when called for by specific Win32 APIs on the Windows platform. On non-Windows platforms, the <xref:System.Runtime.InteropServices.NativeMemory> class should be used to allocate native memory. |
| 2667 | + |
2659 | 2668 | You can use <xref:System.Runtime.InteropServices.Marshal.FreeHGlobal%2A> to free any memory from the global heap allocated by <xref:System.Runtime.InteropServices.Marshal.AllocHGlobal%2A>, <xref:System.Runtime.InteropServices.Marshal.ReAllocHGlobal%2A>, or any equivalent unmanaged API method. If the `hglobal` parameter is <xref:System.IntPtr.Zero?displayProperty=nameWithType> the method does nothing.
|
2660 | 2669 |
|
2661 | 2670 | <xref:System.Runtime.InteropServices.Marshal.FreeHGlobal%2A> exposes the [LocalFree](https://go.microsoft.com/fwlink/?LinkId=148640) function from Kernel32.DLL, which frees all bytes so that you can no longer use the memory pointed to by `hglobal`.
|
@@ -9569,6 +9578,9 @@ On .NET 6 and later versions, this method is functionally equivalent to <xref:Sy
|
9569 | 9578 | <format type="text/markdown"><![CDATA[
|
9570 | 9579 |
|
9571 | 9580 | ## Remarks
|
| 9581 | +> [!IMPORTANT] |
| 9582 | +> This native memory allocator is a legacy API that should be used exclusively when called for by specific Win32 APIs on the Windows platform. On non-Windows platforms, the <xref:System.Runtime.InteropServices.NativeMemory> class should be used to allocate native memory. |
| 9583 | + |
9572 | 9584 | <xref:System.Runtime.InteropServices.Marshal.ReAllocHGlobal%2A> is one of two memory reallocation API methods in the <xref:System.Runtime.InteropServices.Marshal> class. (<xref:System.Runtime.InteropServices.Marshal.ReAllocCoTaskMem%2A?displayProperty=nameWithType> is the other.)
|
9573 | 9585 |
|
9574 | 9586 | This method exposes the Win32 [GlobalReAlloc](https://go.microsoft.com/fwlink/?LinkId=148780) function from Kernel32.dll. The returned pointer can differ from the original. If it is different, the contents of the original memory block have been copied to the new block, and the original memory block has been freed.
|
|
0 commit comments