Clear memory of an object properly between loop iterations? - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Clear memory of an object properly between loop iterations? (/Thread-Clear-memory-of-an-object-properly-between-loop-iterations) |
Clear memory of an object properly between loop iterations? - MGMN - 09-25-2008 I have a question regarding cleaning the memory of objects properly between after the first iteration of a loop. In my QTP script I call a function in order to collect WebElement objects via ChildObjects in order to click on a link in a Table Of Content (TOC) of WebElement objects. Simplified the TOC structure looks like this: Code: Table of contents on screen 1st iteration when going into openBranch function (see code further down): Code: For i = 1 To 5 11 BranchA 12 BranchB This is correct since they are the only objects that fits the Object property. My problem is that when going into the second iteration of the For-Next loop, the List objects that was collected via ChildObjects in the first iteration are now included in the collection again even though they are not shown on the screen as seen below: Code: Table of contents on screen 2nd iteration when going into openBranch function: The collection of objects found via "Set List = parentNode.ChildObjects(oDesc)" are the following: 11 BranchA 12 BranchB 21 BranchC 22 BranchD The question is why the objects from the first iteration are collected when they are not appearing on the screen when sending oDesc to ChildObjects? A guess is that they are saved in the object memory, so how do I clean the memory properly before going into the second iteration? I set "oDesc = Nothing" and "List = Nothing" at the end of the function, but obviously that isn't enough. RE: Clear memory of an object properly between loop iterations? - siri - 09-25-2008 Can you end the iterations one by one .so that the values are not moved fro mthe frst iteratio nto the second RE: Clear memory of an object properly between loop iterations? - MGMN - 09-25-2008 How do you mean "end the iterations one by one"? Could you give an example how to do this in practise? RE: Clear memory of an object properly between loop iterations? - Ankur - 09-25-2008 Append Code: oDesc.Quit Code: Set oDesc = Nothing Let me know if that worked. RE: Clear memory of an object properly between loop iterations? - MGMN - 09-25-2008 I have pasted "oDesc.Quit" before "Set oDesc = Nothing" but I get a run error window with the text: "Object doesn't support this property: 'oDesc.Quit'" RE: Clear memory of an object properly between loop iterations? - Ankur - 09-26-2008 ok, The concept behind this is if any of the instance(copy) of the created object is LIVE(ie the pointer to the object) then the object would not be destroyed...you need to make sure that while passing ByRef ALL the instances are set to Nothing in the end. In your case parentnode may be the problem point. |