Marshal.DestroyStructure メソッド

定義

オーバーロード

DestroyStructure(IntPtr, Type)
古い.

指定したアンマネージ メモリ ブロックが指す、すべてのサブ構造体を解放します。

DestroyStructure<T>(IntPtr)

指定したアンマネージ メモリ ブロックが指す、指定した型のすべてのサブ構造体を解放します。

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

指定したアンマネージ メモリ ブロックが指す、すべてのサブ構造体を解放します。

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

アンマネージ メモリ ブロックへのポインター。

structuretype
Type

書式指定クラスの型。 これは、ptr パラメーター内のバッファーを削除するために必要なレイアウト情報を提供します。

属性

例外

structureType のレイアウトが自動レイアウトです。 代わりに、sequential または explicit を使用します。

注釈

このメソッドを使用すると、アンマネージ構造体の文字列などの参照型フィールドを解放できます。 そのフィールドとは異なり、構造体には値型または参照型を指定できます。 値型フィールド (すべての blittable) を含む値型構造体には、メモリを解放する必要がある参照がありません。 メソッドは Marshal.StructureToPtr 、構造体によって占有されるメモリを再利用するときにメモリ リークを防ぐために、このメソッドを使用します。

DestroyStructure は COM SysFreeString 関数を呼び出します。これにより、割り当てられた文字列が解放されます。

DestroyStructure加えて、 Marshal クラスには、メモリ割り当て解除メソッドと FreeHGlobalという 2 つの他のメソッドが用意されていますFreeCoTaskMem

こちらもご覧ください

適用対象

DestroyStructure<T>(IntPtr)

ソース:
Marshal.cs
ソース:
Marshal.cs
ソース:
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 のレイアウトが自動レイアウトです。 代わりに、sequential または explicit を使用します。

注釈

このメソッドを使用すると、アンマネージ構造体の参照型フィールド (文字列など) を解放できます。 そのフィールドとは異なり、構造体には値型または参照型を指定できます。 値型フィールド (すべての blittable) を含む値型構造体には、メモリを解放する必要がある参照がありません。 メソッドは Marshal.StructureToPtr 、構造体によって占有されるメモリを再利用するときにメモリ リークを防ぐために、このメソッドを使用します。

DestroyStructure は COM SysFreeString 関数を呼び出します。これにより、割り当てられた文字列が解放されます。

適用対象