- hglobal
- The handle returned by the original matching call to Marshal.AllocHGlobal(IntPtr).
You can use Marshal.FreeHGlobal(IntPtr) to free any memory from the global heap allocated by Marshal.AllocHGlobal(IntPtr), Marshal.ReAllocHGlobal(IntPtr, IntPtr), or any equivalent unmanaged API method. If the hglobal parameter is IntPtr.Zero the method does nothing.
Marshal.FreeHGlobal(IntPtr) exposes the tp://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.
In addition to Marshal.FreeHGlobal(IntPtr), the System.Runtime.InteropServices.Marshal class provides two other memory-deallocation API methods: Marshal.DestroyStructure(IntPtr, Type) and Marshal.FreeCoTaskMem(IntPtr).