QTP Tip - Explicitly destroy all objects and close all connections

Share This Post -

Destroying objects and closing connections ensures resources are returned to the system. Objects and connections should be closed and destroyed in the opposite order in which they were created. Wait to create objects and open connections until immediately before they’re needed. Likewise, destroy objects and close connections immediately after you’re through with them.

    1. Example:
    2. Set objFso = Server.CreateObject(“Scripting.FileSystemObject”)
    3. set f = objFSO.OpenTextFile…
    4. f.Close
    5. set f = Nothing
    6. set objRS = Nothing
    7. set objConn = Nothing
    8. set objFso = Nothing