You can use this method to free reference-type fields, such as strings, of an unmanaged structure. Unlike its fields, a structure can be a value type or a reference type. Value-type structures that contain value-type fields (all blittable) have no references whose memory must be freed. The Marshal.StructureToPtr(object, IntPtr, bool) method uses this method to prevent memory leaks when reusing memory occupied by a structure.
Marshal.DestroyStructure(IntPtr, Type) calls the COM tp://go.microsoft.com/fwlink/?LinkId=148633 function, which, in turn, frees an allocated string.
In addition to Marshal.DestroyStructure(IntPtr, Type), the System.Runtime.InteropServices.Marshal class provides two other memory-deallocation methods: Marshal.FreeCoTaskMem(IntPtr) and Marshal.FreeHGlobal(IntPtr).