Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Diferencias entre FREE y DESTROY (https://www.clubdelphi.com/foros/showthread.php?t=11710)

bustio 23-06-2004 05:30:07

Diferencias entre FREE y DESTROY
 
Alguien seria tan amable que me explicara detalladamente cuales son las diferencias entre .FREE y . DESTROY??

GRACIAS!!

jachguate 23-06-2004 05:48:35

En la VCL, destroy es el destructor de la clase, que es un método virtual. Free es un método estático definido en TObject, que valida que no se esté llamando desde una referencia a nil, y llama a Destroy.

Cita:

Empezado por delphi help
Use Free to destroy an object. Free automatically calls the destructor if the object reference is not nil. Any object instantiated at runtime that does not have an owner should be destroyed by a call to Free so that it can be properly disposed of and its memory released. Unlike Destroy, Free is successful even if the object is nil; so if the object was never initialized, Free won’t result in an error.

De hecho, Borland recomienda destruir los objetos llamando a Free y no directamente a Destroy.

Hasta luego.

;)


La franja horaria es GMT +2. Ahora son las 07:02:14.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi