Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Do I declare $vars multiple times?

$
0
0
Hey guys,
maybe some of you noticed that i posted some weeks ago a Topic about 'AutoIt causes memory leak?'. The Bug report got closed and I'm still working on this Script to find the mistake...
Now I've rebuilded the Script back without SQL, without Listviews, and without real .bat files. If the memory of this Script now still rise, it has to me my mistake maybe because I declare some $vars multiple times or I dont know, otherway it has to be a problem of AutoIt. Am I right?

So what I noticed is, I start around 11.600K RAM and after 18 hours I'm around 11.776K RAM ...
Some different Script without SQL, without Listviews, but with real .bat files startet around 11.724K RAM and after 18 hours 13.060K RAM.Thats my Script (w/o SQL, Listview, Batch):

[ autoit ]         
#include #include #include #include Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) OnAutoItExitRegister("_exit") Global $aQueue[1][3] Global $aTasks[5][2] Global $sScriptstatus Global $hGUI = GUICreate("Aufgabenliste", 250, 390) Global $iCounter_label = 0 Global $hCounter_label = GUICtrlCreateLabel("0", 50, 72, 200, 20) Global $hLoadBtn = GUICtrlCreateButton("Load", 140, 40, 100, 30) Global $hStartBtn = GUICtrlCreateButton("Start", 30, 5, 50, 30) Global $hStopBtn = GUICtrlCreateButton("Stop", 30, 40, 50, 30) GUISetState(@SW_SHOW, $hGUI) GUICtrlSetOnEvent($hLoadBtn, "_load") GUICtrlSetOnEvent($hStartBtn, "_check") GUICtrlSetOnEvent($hStopBtn, "_stop_working") GUISetOnEvent($GUI_EVENT_CLOSE, "_exit", $hGUI) While 1 Sleep(100) WEnd Func _load() $aQueue[0][0] = "0" $aQueue[0][1] = "18/01/2013 08:00:00" $aQueue[0][2] = "Test" EndFunc ;==>_load Func _check() $sScriptstatus = True AdlibRegister("_compare_datetimes", 1000) EndFunc ;==>_check Func _compare_datetimes() Local $aRow, $next_date, $aDate If UBound($aQueue) = 0 Then _stop_working() Return 0 EndIf $aRow = StringSplit($aQueue[0][1], " ") $next_date = $aRow[1] $aRow = StringSplit($aRow[2], ":") $aDate = StringSplit($next_date, "/") If $aDate[3] * 365 + $aDate[2] * 30 + $aDate[1] = @YEAR * 365 + @MON * 30 + @MDAY Then If $aRow[1] * 3600 + $aRow[2] * 60 = @HOUR * 3600 + @MIN * 60 + @SEC Or $aRow[1] * 3600 + $aRow[2] * 60 < @HOUR * 3600 + @MIN * 60 + @SEC Then $aRow = 0 $aDate = 0 _start() EndIf ElseIf $aDate[3] * 365 + $aDate[2] * 30 + $aDate[1] < @YEAR * 365 + @MON * 30 + @MDAY Then $aRow = 0 $aDate = 0 _start() EndIf $iCounter_label = $iCounter_label + 1 GUICtrlSetData($hCounter_label, $iCounter_label) $aRow = 0 $next_date = 0 $aDate = 0 EndFunc ;==>_compare_datetimes Func _start() Local $sError, $sStatus, $ShellExecute Local $aBatch[5][5] = [[1, 1, $aQueue[0][1], "Task 1", ""], _ [2, 2, $aQueue[0][1], "Task 2", ""], _ [3, 3, $aQueue[0][1], "Task 3", ""], _ [4, 4, $aQueue[0][1], "Task 4", ""], _ [5, 5, $aQueue[0][1], "_create_next_date", ""]] ReDim $aTasks[5][2] For $i = 0 To UBound($aBatch) - 1 $aTasks[$i][0] = $aBatch[$i][1] * 10 $aTasks[$i][1] = $aBatch[$i][3] Next For $i = 0 To UBound($aBatch) - 1 $sStatus = " ... started" If $aBatch[$i][4] = "" Then $sError = " " _write_log($sError, $aBatch[$i][4], $sStatus) $sError = "OK" $sStatus = " ... finished" _write_log($sError, $aBatch[$i][4], $sStatus) Else $sError = " " _write_log($sError, $aBatch[$i][4], $sStatus) $ShellExecute = Run($aBatch[$i][4], "c:", @SW_HIDE) If $ShellExecute <> 0 Then $sError = "FEHLER" $sStatus = " Something went wrong." Else $sError = "OK" $sStatus = " ... finished" EndIf _write_log($sError, $aBatch[$i][4], $sStatus) EndIf If UBound($aTasks) = 1 Then $aTasks[0][0] = "" $aTasks[0][1] = "" Else _ArrayDelete($aTasks, 0) EndIf Next Sleep(1000) If UBound($aQueue) = 1 Then $aQueue[0][0] = "" $aQueue[0][1] = "" $aQueue[0][2] = "" Else _ArrayDelete($aQueue, 0) EndIf $sError = 0 $sStatus = 0 $ShellExecute = 0 $aBatch = 0 _load() EndFunc ;==>_start Func _stop_working() AdlibUnRegister("_compare_datetimes") $sScriptstatus = False Return 0 EndFunc ;==>_stop_working Func _exit() Exit EndFunc ;==>_exit Func _write_log($sError, $sCommand, $sStatus) Local $hFile $hFile = FileOpen("log_woBATCHwoSQLwoLV.txt", 1) FileWriteLine($hFile, "[" & @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & "][" & $sError & "] " & $sCommand & " " & $sStatus) FileClose($hFile) EndFunc ;==>_write_log

Could you guys please take a look if I'm causing the memory leak or AutoIt?
Maybe some ohter Informations: I wrote Testscripts for Run, RunWait (and both with @ComSpec), ShellExecute,ShellExecuteWait (and both with CMD) and the only two commands where memory isnt rising is Run and RunWait without @ComSpec!Then I wrote some Testscript to check if my funktion write_log maybe causes a memory leak. Did the test 2 times, both with 100.000 times of writing, and closing file, memory stayed same.

I hope some of you can help me, working for 2 1/2 months on my real script now and dunno if it makes sense to try to finish it in AutoIt :/
Regards

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>