Wednesday, 20 March 2013

used and what's the difference between FreeAndNil and Free method

Free -  Deallocate the memory previously allocated for the object
nil - Dereference the object

When an object is created like

Query1 := TQuery.Create(nil)

It creates the instance and allocate some memory space to hold the data of Query1

When Free is called - It frees the memory of space already allocated for Query1
When nil is called - It sets the pointer to  nil

Always try to use FreeAndNil instead of Free And Nil separately

No comments:

Post a Comment