A pointer to the newly allocated memory. This memory must be released using the Marshal.FreeHGlobal(IntPtr) method.
Marshal.AllocHGlobal(IntPtr) is one of two memory allocation methods in the System.Runtime.InteropServices.Marshal class. (Marshal.AllocCoTaskMem(int) is the other.) This method exposes the Win32 tp://go.microsoft.com/fwlink/?LinkId=148628 function from Kernel32.dll.
When Marshal.AllocHGlobal(int) 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.