Marshal.DestroyStructure メソッド

定義

オーバーロード

名前 説明
DestroyStructure(IntPtr, Type)
古い.

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

DestroyStructure<T>(IntPtr)

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

DestroyStructure(IntPtr, Type)

ソース:
Marshal.CoreCLR.cs
ソース:
Marshal.CoreCLR.cs
ソース:
Marshal.cs
ソース:
Marshal.cs
ソース:
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という他の 2 つのメモリ解放メソッドが用意されています。

こちらもご覧ください

適用対象

DestroyStructure<T>(IntPtr)

ソース:
Marshal.cs
ソース:
Marshal.cs
ソース:
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 には自動レイアウトがあります。 代わりにシーケンシャルまたは明示的を使用してください。

注釈

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

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

適用対象