PDA

Ver la Versión Completa : Diferencias entre FREE y DESTROY


bustio
23-06-2004, 05:30:07
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.


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.

;)