Marshal.DestroyStructure Método
Definição
Sobrecargas
| DestroyStructure(IntPtr, Type) |
Obsoleto.
Libera todas as subestruturas para as quais o bloco de memória não gerenciada especificado aponta.Frees all substructures that the specified unmanaged memory block points to. |
| DestroyStructure<T>(IntPtr) |
[Suporte somente no .NET Framework 4.5.1 e versões posteriores][Supported in the .NET Framework 4.5.1 and later versions] Libera todas as subestruturas de um tipo especificado para as quais o bloco de memória não gerenciado especificado aponta.Frees all substructures of a specified type that the specified unmanaged memory block points to. |
DestroyStructure(IntPtr, Type)
Cuidado
DestroyStructure(IntPtr, Type) may be unavailable in future releases. Instead, use DestroyStructure(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296520
Libera todas as subestruturas para as quais o bloco de memória não gerenciada especificado aponta.Frees all substructures that the specified unmanaged memory block points to.
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)
Parâmetros
- ptr
- IntPtr
Um ponteiro para um bloco não gerenciado de memória.A pointer to an unmanaged block of memory.
- structuretype
- Type
Tipo de uma classe formatada.Type of a formatted class. Isso fornece as informações de layout necessárias para excluir o buffer no parâmetro ptr.This provides the layout information necessary to delete the buffer in the ptr parameter.
- Atributos
Exceções
structureType tem um layout automático.structureType has an automatic layout. Use explícito ou sequencial no seu lugar.Use sequential or explicit instead.
Comentários
Você pode usar esse método para liberar campos de tipo de referência, como cadeias de caracteres, de uma estrutura não gerenciada.You can use this method to free reference-type fields, such as strings, of an unmanaged structure. Ao contrário de seus campos, uma estrutura pode ser um tipo de valor ou um tipo de referência.Unlike its fields, a structure can be a value type or a reference type. Estruturas de tipo de valor que contêm campos de tipo de valor (todos os blittables) não têm nenhuma referência cuja memória deva ser liberada.Value-type structures that contain value-type fields (all blittable) have no references whose memory must be freed. O Marshal.StructureToPtr método usa esse método para evitar vazamentos de memória ao reutilizar a memória ocupada por uma estrutura.The Marshal.StructureToPtr method uses this method to prevent memory leaks when reusing memory occupied by a structure.
DestroyStructure chama a função SYSFREESTRING com, que, por sua vez, libera uma cadeia de caracteres alocada.DestroyStructure calls the COM SysFreeString function, which, in turn, frees an allocated string.
Além disso DestroyStructure , a Marshal classe fornece dois outros métodos de desalocação de memória: FreeCoTaskMem e FreeHGlobal .In addition to DestroyStructure, the Marshal class provides two other memory-deallocation methods: FreeCoTaskMem and FreeHGlobal.
Confira também
- FreeCoTaskMem(IntPtr)
- FreeHGlobal(IntPtr)
- Tipos blittable e não blittableBlittable and Non-Blittable types
Aplica-se a
DestroyStructure<T>(IntPtr)
[Suporte somente no .NET Framework 4.5.1 e versões posteriores][Supported in the .NET Framework 4.5.1 and later versions]
Libera todas as subestruturas de um tipo especificado para as quais o bloco de memória não gerenciado especificado aponta.Frees all substructures of a specified type that the specified unmanaged memory block points to.
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)
Parâmetros de tipo
- T
O tipo da estrutura formatada.The type of the formatted structure. Isso fornece as informações de layout necessárias para excluir o buffer no parâmetro ptr.This provides the layout information necessary to delete the buffer in the ptr parameter.
Parâmetros
- ptr
- IntPtr
Um ponteiro para um bloco não gerenciado de memória.A pointer to an unmanaged block of memory.
- Atributos
Exceções
T tem um layout automático.T has an automatic layout. Use explícito ou sequencial no seu lugar.Use sequential or explicit instead.
Comentários
Você pode usar esse método para liberar campos de tipo de referência, como cadeias de caracteres, de uma estrutura não gerenciada.You can use this method to free reference type fields, such as strings, of an unmanaged structure. Ao contrário de seus campos, uma estrutura pode ser um tipo de valor ou um tipo de referência.Unlike its fields, a structure can be a value type or a reference type. Estruturas de tipo de valor que contêm campos de tipo de valor (todas as blittables) não têm nenhuma referência cuja memória deva ser liberada.Value type structures that contain value type fields (all blittable) have no references whose memory must be freed. O Marshal.StructureToPtr método usa esse método para evitar vazamentos de memória ao reutilizar a memória ocupada por uma estrutura.The Marshal.StructureToPtr method uses this method to prevent memory leaks when reusing memory occupied by a structure.
DestroyStructure chama a função SYSFREESTRING com, que, por sua vez, libera uma cadeia de caracteres alocada.DestroyStructure calls the COM SysFreeString function, which, in turn, frees an allocated string.