Advanced PowerBuilder

HomePrevious Lesson: Creating an Instance
Next Lesson: Garbage Collection

Destroying an Instance

There are two ways of destroying an instance. It depends on how the object was created. If the instance was created using one of the Open function, you should use the Close() function:
Close() /* Clears an instance of a window from the
screen and from memory */
CloseUserObject() /* Clears an instance of a User Object
from the screen and from memory */

If it was created by using the CREATE statement (a transaction object, for example), you should use the DESTROY statement:
DESTROY <Object Name> // Removes the object from memory

You can only create and destroy one object at a time. When you create an instance, by declaring the variable as a local variable, it is destroyed automatically after the execution of the script. However, it is a good programming practice to explicitly destroy all objects created by Create, by using the Destroy command.
HomePrevious Lesson: Creating an Instance
Next Lesson: Garbage Collection