Marshal.DestroyStructure 方法

定義

多載

DestroyStructure(IntPtr, Type)
已淘汰.

釋放指定之 Unmanaged 記憶體區塊指向的所有子結構。

DestroyStructure<T>(IntPtr)

釋放指定之 Unmanaged 記憶體區塊指向的所有指定類型的子結構。

DestroyStructure(IntPtr, Type)

來源:
Marshal.cs
來源:
Marshal.cs
來源:
Marshal.CoreCLR.cs

警告

DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296520

釋放指定之 Unmanaged 記憶體區塊指向的所有子結構。

public:
 static void DestroyStructure(IntPtr ptr, Type ^ structuretype);
[System.Obsolete("DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296520")]
[System.Security.SecurityCritical]
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). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296520")>]
[<System.Security.SecurityCritical>]
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

Unmanaged 記憶體區塊的指標。

structuretype
Type

格式化類別的類型。 這提供刪除 ptr 中的緩衝區時所必須的配置資訊。

屬性

例外狀況

structureType 有自動配置。 使用循序或明確取代。

備註

您可以使用這個方法來釋放 Unmanaged 結構的參考型別欄位,例如字串。 與其欄位不同,結構可以是實值型別或參考型別。 包含實值型別字段的實數值型別結構, (所有 blittable) 沒有必須釋放其記憶體的參考。 方法 Marshal.StructureToPtr 會使用這個方法來防止重複使用結構所佔用的記憶體時發生記憶體流失。

DestroyStructure 會呼叫 COM SysFreeString 函式,接著釋放配置的字串。

除了 DestroyStructure 之外,類別 Marshal 還提供兩個其他記憶體解除配置方法: FreeCoTaskMemFreeHGlobal

另請參閱

適用於

DestroyStructure<T>(IntPtr)

來源:
Marshal.cs
來源:
Marshal.cs
來源:
Marshal.cs

釋放指定之 Unmanaged 記憶體區塊指向的所有指定類型的子結構。

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

Unmanaged 記憶體區塊的指標。

屬性

例外狀況

T 有自動配置。 使用循序或明確取代。

備註

您可以使用這個方法來釋放非受控結構的參考型別字段,例如字串。 與其欄位不同,結構可以是實值型別或參考型別。 包含實值型別字段的值型別結構 (所有 blittable) 沒有必須釋放記憶體的參考。 方法 Marshal.StructureToPtr 會使用這個方法來防止重複使用結構所佔用的記憶體時發生記憶體流失。

DestroyStructure 會呼叫 COM SysFreeString 函式,接著釋放配置的字串。

適用於