Micro Focus QTP (UFT) Forums
Is there a way to free up the memory used by the variables during run time? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Is there a way to free up the memory used by the variables during run time? (/Thread-Is-there-a-way-to-free-up-the-memory-used-by-the-variables-during-run-time)



Is there a way to free up the memory used by the variables during run time? - ritesh - 06-18-2009

Hi Ankur,

When I run a huge script I'm facing 'Out Of Memory' error.
I have tried my best
i) to reduce the use of variable
ii) not to pass data through DataTables.

I'm passing the required data through .ini file.

But at few places i have used variables to save the values fetched from GetROProperty.

Is there a way to free up the memory used by these variables(during run time)?

Please help me in this regard.

Thanks,
Ritesh


RE: Is there a way to free up the memory used by the variables during run time? - ursvinod - 06-19-2009

Hi Ritesh,

We can free up the memory of the variables by using Nothing.

Example:

Code:
Dim a,b

a=10
b= 30

a = Nothing ' Nothing will remove data in the variable but it does not delete the variable



RE: Is there a way to free up the memory used by the variables during run time? - ritesh - 06-19-2009

Hi Vinod,
Thank u very much.
I was using 'NOTHING' for objects... I was not knowing that I can use it for variables too...
Thanks a lot.


RE: Is there a way to free up the memory used by the variables during run time? - ursvinod - 06-22-2009

Hi Ritesh,

First of all sorry for my answer, you are correct 'Nothing' can be used only for Objects.

The solution for issue is here,

You should be Using 'Empty' to free up the memory for a variable

example:

Code:
Dim a

a= 120
Msgbox LenB(a)
' this will return 6. LenB means - "The LenB function returns the number of bytes used to represent that string."

' Now memory used by 'a' is 6 bytes.

a = Empty

Msgbox LenB(a) ' This will reture zero which means that the memory used by a is zero

Hope this will solve your problem.

Thanks
Vinod


RE: Is there a way to free up the memory used by the variables during run time? - ritesh - 06-23-2009

Hi Vinod,

Thank u very much for replying and explaining me in detail.

Regards,
Ritesh


RE: Is there a way to free up the memory used by the variables during run time? - ritesh - 07-06-2009

Hi Vinod,

As we use 'Empty' to free up the memory for a variable, is there any other way to free up the memory allocated for an array.

Like if i have declared an array as 'Dim arrStudentName(25)'
What do i need to do if I want to clear the memory used by this array ?

Thanks,
Ritesh