Need help - Memory leak in iMacros browser through AutoIT Scripts

vaish

Solid State Member
Messages
6
I am running one AutoIT scripts and in that scripts it has Imacros Browser of creating and deleting of imacros objects by calling imacros function..I observed that available physical memory in PC was kept on reducing after running for so long, there isn't any memory left for it to run. Thus Imacros browser fail to run...
How to solve this issue and how to optimize the script?

Please share any logics or ideas on this.
Script:
Func main()
;Creating IMacros Object
Global $iMacros = ObjCreate("IMacros")
Global $iRet
If Not IsObj($iMacros) Then
KConsoleWrite("IMacro Object not created successfully")
KConsoleWrite("Closing Program", 1)
Else
if StringInStr($isVisible, "no") Then
$iRet = $iMacros.iimInit("-tray")
Else
$iRet = $iMacros.iimInit()
EndIf
$count = 0
While $iRet = -1
$count = $count + 1
KConsoleWrite("IMacro not initialized successfully. Retrying")
if StringInStr($isVisible, "no") Then
$iRet = $iMacros.iimInit("-tray")
Else
$iRet = $iMacros.iimInit()
EndIf
Sleep(2000)
If $count = 6 Then
KConsoleWrite("IMacro not initialized successfully.")
KConsoleWrite("Exiting with error code " & $iRet, 1)
ExitLoop
EndIf
WEnd
EndIf

;the two routines that you need to run
Global $iMacroTorun = Eval("imacrosFile")
Global $iMacroStatus

$iMacros.iimDisplay("Testing is in Progress...")
IMacrosSetArguments()
$iMacroStatus = IMacrosPlay($iMacroTorun)
IMacrosCheckError($iMacroStatus)

;Delete IMacros Object
$iMacros.iimDisplay("Testing is finished...")
$iMacros.iimExit()

;Handle Comparision
if IsDeclared("Comparison") Then
;Read output file into variable
local $text=KFileReadToArray(eval("outputFile"))
if $text[0] = 0 Then
KConsoleWrite("Imacros Ext gave empty output",1)
EndIf

;stripping leading and trailing white spaces
local $mytext = StringStripWS($text[1], 3)
;stripping any double quote char
$mytext = StringReplace($mytext,'"',"")

Switch eval("Comparison")
Case "equal"
if $mytext = eval("Pattern") Then
KConsoleWrite("Equal passed: "&eval("Pattern"))
Else
KConsoleWrite("Equal failed: " & $mytext & ", while looking for " & eval("Pattern"))
$programExitCode=1
EndIf
Case "lessthan"
if int($mytext) <= int(eval("Pattern")) Then
KConsoleWrite("Less Than passed: " &$mytext & " is less than " & eval("Pattern"))
Else
KConsoleWrite("Less Than passed: " &$mytext & " is not less than " & eval("Pattern"))
$programExitCode=1
EndIf
Case "lessthanequal"
if int($mytext) < int(eval("Pattern")) Then
KConsoleWrite("Less Than passed: " &$mytext & " is less than or equal " & eval("Pattern"))
Else
KConsoleWrite("Less Than passed: " &$mytext & " is not less than or equal " & eval("Pattern"))
$programExitCode=1
EndIf
Case "greater"
if int($mytext) > int(eval("Pattern")) Then
KConsoleWrite("Less Than passed: " &$mytext & " is greater than " & eval("Pattern"))
Else
KConsoleWrite("Less Than passed: " &$mytext & " is not greater than " & eval("Pattern"))
$programExitCode=1
EndIf
Case "greaterequal"
if int($mytext) >= int(eval("Pattern")) Then
KConsoleWrite("Less Than passed: " &$mytext & " is greater than " & eval("Pattern"))
Else
KConsoleWrite("Less Than passed: " &$mytext & " is not greater than " & eval("Pattern"))
$programExitCode=1
EndIf
Case Else
KConsoleWrite("Invalid Compare option: "&eval("Compare"),1)
EndSwitch
EndIf
EndFunc


 
Back
Top Bottom