Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
moibelgal Absent Member.
Absent Member.
260 views

OTAClient Memory Leakage

Hi experts,

I have a small program to get the tests list in QC. The problem is memory usage of this program remains the same when the QC stuffs completed and I did use ReleaseConnection and set td object = null to clean up resource.

After that, I checked a sample in OTA API Reference and the way it releases the td object similar to mine. Amazingly, when I tried to execute this vbscript, the memory can not be reduced as well! Here is the code:

Sub CheckConnection
Dim qcServer: qcServer = "http://devserver/qcbin"

Dim tdc: Set tdc = CreateObject("TDApiOle80.TDConnection")

'MsgBox "Init"
tdc.InitConnectionEx qcServer

'MsgBox "Login"
tdc.Login "administrator", ""

'MsgBox "Connect"
tdc.Connect "Dom1", "Prj1"

If tdc.Connected Then
'MsgBox "Disconnecting..."
tdc.Disconnect
End If

If (tdc.Connected = false) Then
' MsgBox "Disconnect"
End If

If tdc.LoggedIn Then
tdc.Logout
End If

If (tdc.LoggedIn = false) Then
' MsgBox "Log out"
End If

'MsgBox "Release connection"
tdc.ReleaseConnection

Set tdc = Nothing
End Sub

Function getCurrentProcessSize()
Set objSWbemServices = GetObject ("WinMgmts:Root\Cimv2")
Set colProcess = objSWbemServices.ExecQuery _
("Select * From Win32_Process")
For Each objProcess In colProcess
If InStr (objProcess.CommandLine, WScript.ScriptName) <> 0 Then
getCurrentProcessSize = objProcess.WorkingSetSize & " bytes"
End If
Next
End Function

Dim before: before = getCurrentProcessSize()
msgbox "Memory before connecting: " & before
CheckConnection()
msgbox "Done." & VbCrlf & "Memory before connecting: " & before & _
VbCrlf & "Memory after releasing: " & getCurrentProcessSize()

The getCurrentProcessSize function is to get the memory usage of wscript object. Pls feel free to remove (use Task Manager instead)

Is it OTAClient memory leakage or I have missed to do something to clean up completely? Is there any solution for this?

I'm using QC 9.2

Thanks
0 Likes
7 Replies
Micro Focus Expert
Micro Focus Expert

Re: OTAClient Memory Leakage

set td object = null only instructs the garbage collector that this object is no longer needed and can be cleaned up when appropriate. The gargabe collector usually does not start the cleanup immediately.
0 Likes
Highlighted
moibelgal Absent Member.
Absent Member.

Re: OTAClient Memory Leakage

Hi Thomas,

Did you mean set td object = Nothing will not work? If so, how can we clean up?

Thanks,
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: OTAClient Memory Leakage

It works, but not immediately. For performance purposes VB does not free the memory immediately. It is marked as free in the process of course, but you will not necessarily see the process memory usage decrease.

Usually right after a program frees some objects some lines later it creates new objects and therefore the previously freed memory is been reused without reducing and enlarging the process size in between these steps which would cost much more CPU usage.

When your VB script ends all memory should be freed. There will be no memory leak.

0 Likes
moibelgal Absent Member.
Absent Member.

Re: OTAClient Memory Leakage

Hi Thomas,

Maybe you misunderstood my point. To make things clear, could you please execute the script above? Here is my result:
Memory usage for wscript:
- Before working with OTA: 5M
- After releasing connection: 15M
- 2 mins after: 14M (see Task Manager)
- 30 mins after: remain 14M (see Task Manager)

Obviously, the memory usage is not reduced after long time.
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: OTAClient Memory Leakage

This is VBS. It does not free memory often. I has nothing to do with QC. Try this:


Sub CheckConnection()
Dim dict : Set dict = CreateObject("Scripting.Dictionary")
for i = 1 to 100
dict.Add i, i & "test"
Next
Set dict = Nothing
End Sub

Function getCurrentProcessSize()
Dim objSWbemServices : Set objSWbemServices = GetObject ("WinMgmts:Root\Cimv2")
Dim colProcess : Set colProcess = objSWbemServices.ExecQuery ("Select * From Win32_Process")
Dim objProcess : For Each objProcess In colProcess
If InStr (objProcess.CommandLine, WScript.ScriptName) <> 0 Then
getCurrentProcessSize = objProcess.WorkingSetSize & " bytes"
End If
Next
End Function

Dim before: before = getCurrentProcessSize()
msgbox "Memory before connecting: " & before
CheckConnection()
MsgBox "Wait..."
msgbox "Done." & VbCrlf & "Memory before connecting: " & Split(before)(0) / (1024.0 * 1024.0) & _
VbCrlf & "Memory after releasing: " & Split(getCurrentProcessSize())(0) / (1024.0 * 1024.0)
0 Likes
moibelgal Absent Member.
Absent Member.

Re: OTAClient Memory Leakage

I tried this, the memory is increased slightly: from 5M to 6M. When we work with OTA, memory goes up 15M and remain 14MB unless we dispose the script.
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: OTAClient Memory Leakage

This is correct. The dictionaty object is not very large. It is actually a quite simlpe object. So the difference is not the same as with the QC connection. But the behavior is the same: VBS does not reduce the process size. I wanted to show you by this example that this is normal VBS behaior and has nothing to do with QC. Hope this helps.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.