Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to free up the memory used by the variables during run time?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
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.
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi Vinod,

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

Regards,
Ritesh
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Function That Creates WebLink Variables Eitel13 3 1,493 07-17-2018, 03:25 PM
Last Post: Ankur
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,714 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  HI, i'm having a run time error ,please help? Awzar 0 2,638 01-24-2015, 06:52 AM
Last Post: Awzar
  Maintenance free Automation, irrespective of any changes done on GUI siteshag 0 2,001 07-01-2014, 02:50 PM
Last Post: siteshag
  Loading objects in qtp at run time nitin 0 2,420 12-03-2013, 09:11 PM
Last Post: nitin

Forum Jump:


Users browsing this thread: 1 Guest(s)