Condividi tramite


Marshal.DestroyStructure Metodo

Definizione

Overload

Nome Descrizione
DestroyStructure(IntPtr, Type)
Obsoleti.

Libera tutte le sottostruttura a cui punta il blocco di memoria non gestito specificato.

DestroyStructure<T>(IntPtr)

Libera tutte le sottostruttura di un tipo specificato a cui punta il blocco di memoria non gestito specificato.

DestroyStructure(IntPtr, Type)

Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.CoreCLR.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.CoreCLR.cs

Attenzione

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

Libera tutte le sottostruttura a cui punta il blocco di memoria non gestito specificato.

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)

Parametri

ptr
IntPtr

nativeint

Puntatore a un blocco di memoria non gestito.

structuretype
Type

Tipo di una classe formattata. In questo modo vengono fornite le informazioni di layout necessarie per eliminare il buffer nel ptr parametro .

Attributi

Eccezioni

structuretype ha un layout automatico. Usare invece sequenziale o esplicito.

Commenti

È possibile utilizzare questo metodo per liberare campi di tipo riferimento, ad esempio stringhe, di una struttura non gestita. A differenza dei relativi campi, una struttura può essere un tipo valore o un tipo riferimento. Le strutture di tipo valore che contengono campi di tipo valore (tutti copiabili) non hanno riferimenti la cui memoria deve essere liberata. Il Marshal.StructureToPtr metodo usa questo metodo per evitare perdite di memoria quando si riutilizza la memoria occupata da una struttura.

DestroyStructure chiama la funzione SYSFreeString COM, che a sua volta libera una stringa allocata.

Oltre a DestroyStructure, la Marshal classe fornisce altri due metodi di deallocazione della memoria: FreeCoTaskMem e FreeHGlobal.

Vedi anche

Si applica a

DestroyStructure<T>(IntPtr)

Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs
Origine:
Marshal.cs

Libera tutte le sottostruttura di un tipo specificato a cui punta il blocco di memoria non gestito specificato.

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)

Parametri di tipo

T

Tipo della struttura formattata. In questo modo vengono fornite le informazioni di layout necessarie per eliminare il buffer nel ptr parametro .

Parametri

ptr
IntPtr

nativeint

Puntatore a un blocco di memoria non gestito.

Attributi

Eccezioni

T ha un layout automatico. Usare invece sequenziale o esplicito.

Commenti

È possibile utilizzare questo metodo per liberare campi di tipo riferimento, ad esempio stringhe, di una struttura non gestita. A differenza dei relativi campi, una struttura può essere un tipo valore o un tipo riferimento. Le strutture dei tipi di valore che contengono campi di tipo valore (tutti copiabili da blt) non hanno riferimenti la cui memoria deve essere liberata. Il Marshal.StructureToPtr metodo usa questo metodo per evitare perdite di memoria quando si riutilizza la memoria occupata da una struttura.

DestroyStructure chiama la funzione SYSFreeString COM, che a sua volta libera una stringa allocata.

Si applica a