4DQuiz


OT IsObject,OT Clear View from small screen devices!  

OT IsObject, OT Clear

Parameter Type  Description
ioObject Longint A handle to an object
Discussion    

When you are finished with an object, you should always call OT Clear to release the memory occupied by the object. If you create an object and then lose track of its handle, you will no longer be able to release its memory. This is known as a leak, and it is considered a Bad Thing.

ObjectTools maintains an internal list of all objects that have been created but not cleared. When an object is disposed of with OT Clear, it is removed from the list. The current list of created objects is available with the OT GetHandleList method.

You can actually release the memory used by leaked objects with OT GetHandleList or OT ClearAll. However, using these as a means of object memory management is not recommended.

It you pass a variable directly to OT Clear (as opposed to an extremely lucky guess at a number constant), the variable will be set to zero.

Note It is legal to pass a null handle (0) to OT Clear.

Examples

The sample code is below demonstrates creating two temporary objects to pass to a method. The first one will leak, while the second one is properly disposed with OT Clear.

C_LONGINT($leak;$notLeak) $leak:=OT New OT PutString ($leak;"name";[Contacts]Name) $notLeak:=OT New OT PutString ($notLeak;"address";[Contacts]Address) MyMethod($leak;$notLeak) OT Clear ($notLeak) `The memory is released

`If we leave this method at this point, we will not be able to recover `the value of $leak, so its memory will leak.

See Also

OT New , OT ClearAll



Topics of Interest
Creation and Destruction Routines
OT New
OT Copy
Import/Export Routines
OT GetObject
OT ObjectToNewBLOB
 

Published date: Fri, 14 Jul 2006 18:41:43 GMT   → View XML Version

Edit this page now

© 2005 - 2006 4dquiz.com, All trademarks accepted. All Rights Reserved!
Site Index