Marshal.DestroyStructure 方法

定义

重载

名称 说明
DestroyStructure(IntPtr, Type)
已过时.

释放指定非托管内存块指向的所有子结构。

DestroyStructure<T>(IntPtr)

释放指定非托管内存块指向的指定类型的所有子结构。

DestroyStructure(IntPtr, Type)

Source:
Marshal.CoreCLR.cs
Source:
Marshal.CoreCLR.cs
Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.CoreCLR.cs

注意

DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure<T>(IntPtr).

释放指定非托管内存块指向的所有子结构。

public:
 static void DestroyStructure(IntPtr ptr, Type ^ structuretype);
[System.Obsolete("DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure<T>(IntPtr).")]
[System.Security.SecurityCritical]
public static void DestroyStructure(IntPtr ptr, Type structuretype);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the object might not be available. Use the DestroyStructure<T> overload instead.")]
public static void DestroyStructure(IntPtr ptr, Type structuretype);
public static void DestroyStructure(IntPtr ptr, Type structuretype);
[System.Security.SecurityCritical]
public static void DestroyStructure(IntPtr ptr, Type structuretype);
[System.Runtime.InteropServices.ComVisible(true)]
public static void DestroyStructure(IntPtr ptr, Type structuretype);
[System.Security.SecurityCritical]
[System.Runtime.InteropServices.ComVisible(true)]
public static void DestroyStructure(IntPtr ptr, Type structuretype);
[<System.Obsolete("DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure<T>(IntPtr).")>]
[<System.Security.SecurityCritical>]
static member DestroyStructure : nativeint * Type -> unit
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Marshalling code for the object might not be available. Use the DestroyStructure<T> overload instead.")>]
static member DestroyStructure : nativeint * Type -> unit
static member DestroyStructure : nativeint * Type -> unit
[<System.Security.SecurityCritical>]
static member DestroyStructure : nativeint * Type -> unit
[<System.Runtime.InteropServices.ComVisible(true)>]
static member DestroyStructure : nativeint * Type -> unit
[<System.Security.SecurityCritical>]
[<System.Runtime.InteropServices.ComVisible(true)>]
static member DestroyStructure : nativeint * Type -> unit
Public Shared Sub DestroyStructure (ptr As IntPtr, structuretype As Type)

参数

ptr
IntPtr

nativeint

指向非托管内存块的指针。

structuretype
Type

格式化类的类型。 这提供了删除参数中 ptr 缓冲区所需的布局信息。

属性

例外

structuretype 具有自动布局。 请改用顺序或显式。

注解

可以使用此方法释放非托管结构的引用类型字段,例如字符串。 与其字段不同,结构可以是值类型或引用类型。 包含值类型字段(所有 blittable)的值类型结构没有必须释放其内存的引用。 此方法 Marshal.StructureToPtr 使用此方法在重用结构占用的内存时防止内存泄漏。

DestroyStructure 调用 COM SysFreeString 函数,后者反过来释放分配的字符串。

此外 DestroyStructure,该 Marshal 类还提供另外两种内存解除分配方法: FreeCoTaskMemFreeHGlobal

另请参阅

适用于

DestroyStructure<T>(IntPtr)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

释放指定非托管内存块指向的指定类型的所有子结构。

public:
generic <typename T>
 static void DestroyStructure(IntPtr ptr);
[System.Security.SecurityCritical]
public static void DestroyStructure<T>(IntPtr ptr);
public static void DestroyStructure<T>(IntPtr ptr);
[<System.Security.SecurityCritical>]
static member DestroyStructure : nativeint -> unit
static member DestroyStructure : nativeint -> unit
Public Shared Sub DestroyStructure(Of T) (ptr As IntPtr)

类型参数

T

格式化结构的类型。 这提供了删除参数中 ptr 缓冲区所需的布局信息。

参数

ptr
IntPtr

nativeint

指向非托管内存块的指针。

属性

例外

T 具有自动布局。 请改用顺序或显式。

注解

可以使用此方法释放非托管结构的引用类型字段,例如字符串。 与其字段不同,结构可以是值类型或引用类型。 包含值类型字段(所有 blittable)的值类型结构没有必须释放其内存的引用。 此方法 Marshal.StructureToPtr 使用此方法在重用结构占用的内存时防止内存泄漏。

DestroyStructure 调用 COM SysFreeString 函数,后者反过来释放分配的字符串。

适用于