User Guide > User Guide > Scripting > Variables > Clearing Variables and Array Elements
Was this helpful?
Clearing Variables and Array Elements
Clear any declared object variable or array element containing objects as soon as it is no longer needed. An uncleared variable can decrease performance by absorbing valuable resources on the system, long after its usefulness has ended.
A handy place to clear public variables is the Stop step in the Process window. If the variable is used for only a few steps in a large process, use a Script step to clear the variable right after the last step that requires it.
Local variables are automatically released when the function in which they were defined exits.
Private variables are released when the transformation is complete.
Examples of Clearing Variables and Array Elements
The following example shows how to clear an object variable:
Set variablename = Nothing
The following example shows how to clear an array element:
MyArray(0) = Null
The following example shows how to clear an array element using the Null function:
MyArray(1) = Null()
The following example shows how to clear all array elements simultaneously by looping through the array. The array was initialized to contain 100 elements:
Dim i
For i = 0 To 99
MyArray = Null
Next i
Note:  An array is destroyed then recreated when the ReDim statement is used to resize it. Excessive use of ReDim may fragment memory and decrease performance. See ReDim Statement.
Last modified date: 01/25/2022