DESTROY
Description
Eliminates an object instance that was created with the CREATE statement. After
a DESTROY statement, properties of the deleted
object instance can no longer be referenced.
Syntax
|
1 |
DESTROY <span>objectvariable</span> |
|
Parameter |
Description |
|---|---|
|
objectvariable |
A variable whose datatype is a PowerBuilder |
Usage
When you are finished with an object that you created, you
can call DESTROY to release its memory. However,
you should call DESTROY only if you are sure that
the object is not referenced by any other object. PowerBuilder’s
garbage collection mechanism maintains a count of references to
each object and destroys unreferenced objects automatically.
For more information about garbage collection,
see “Garbage collection”.
All objects are destroyed automatically when your application
terminates.
Examples
The following statement destroys the transaction object DBTrans that
was created with a CREATE statement:
|
1 |
DESTROY DBTrans |
This example creates an OLEStorage variable istg_prod_pic in
a window’s Open event. When the window is closed, the Close
event script destroys the object. The variable’s declaration
is:
|
1 |
OLEStorage istg_prod_pic |
The window’s Open event creates an object
instance and opens an OLE storage file:
|
1 |
integer li_result |
|
1 |
istg_prod_pic = CREATE OLEStorage |
|
1 |
li_result = stg_prod_pic.Open("PICTURES.OLE") |
The window’s Close event destroys istg_prod_pic:
|
1 |
integer li_result |
|
1 |
li_result = istg_prod_pic.Save( ) |
|
1 |
IF li_result = 0 THEN |
|
1 |
DESTROY istg_prod_pic |
|
1 |
END IF |