LucML Posted July 16, 2010 Share Posted July 16, 2010 (edited) Hi all, I have a memory leak issue with my script and I can't figure out why. My script runs 24/7. As you can see there is an endless loop. After 24 to 48 h the memory usage is at 1GB and the script crash. You will not be able to run the script since it queries a software that you don't have access too. But maybe by looking at the code you can help me? See my code below. Thanks. Do WinWait("Queues") $TotalColumns = ControlListView ("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetSubItemCount") $TotalAgents = ControlListView ("Queues", "", 59664, "GetItemCount") FileOpen ($file, 130) Do $AgentStatus = ControlListView ("Queues", "", 59664, "GetText", $i, "0") $AgentTime = ControlListView ("Queues", "", 59664, "GetText", $i, "1") If $AgentStatus <> "" Then FileWriteLine($file, $AgentStatus & ";" & $AgentTime) EndIf $AgentStatus = "" $AgentTime = "" $i = $i + 1 Until $i = $TotalAgents $i = 0 Do $DataQueue = ControlListView ("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", "0", $i) FileWriteLine($file, $DataQueue) $i = $i + 1 $DataQueue = "" Until $i = $TotalColumns FileClose ($file) $i = 0 Sleep (5000) $TotalColumns = "" $TotalAgents = "" Until 2 = 1 Edited July 16, 2010 by LucML Link to comment Share on other sites More sharing options...
LucML Posted July 16, 2010 Author Share Posted July 16, 2010 (edited) Ooops I forgot a part of my script. Here is the complete script. expandcollapse popupWinWait("Queues") $i = 0 $path= "C:\inetpub\wwwroot\agentstatus\" $file= $path & "status.txt" Do WinWait("Queues") $TotalColumns = ControlListView ("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetSubItemCount") $TotalAgents = ControlListView ("Queues", "", 59664, "GetItemCount") FileOpen ($file, 130) Do $AgentStatus = ControlListView ("Queues", "", 59664, "GetText", $i, "0") $AgentTime = ControlListView ("Queues", "", 59664, "GetText", $i, "1") If $AgentStatus <> "" Then FileWriteLine($file, $AgentStatus & ";" & $AgentTime) EndIf $AgentStatus = "" $AgentTime = "" $i = $i + 1 Until $i = $TotalAgents $i = 0 Do $DataQueue = ControlListView ("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", "0", $i) FileWriteLine($file, $DataQueue) $i = $i + 1 $DataQueue = "" Until $i = $TotalColumns FileClose ($file) $i = 0 Sleep (5000) $TotalColumns = "" $TotalAgents = "" Until 2 = 1 Edited July 16, 2010 by LucML Link to comment Share on other sites More sharing options...
KaFu Posted July 16, 2010 Share Posted July 16, 2010 (edited) You do a FileOpen()... but don't use the handle in the subsequent operations! And finally the FileClose($file) doesn't close the opend handle, so the orphaned FileOpen() handles pile up to the sky... Do WinWait("Queues") $TotalColumns = ControlListView("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetSubItemCount") $TotalAgents = ControlListView("Queues", "", 59664, "GetItemCount") $hfile = FileOpen($file, 130) Do $AgentStatus = ControlListView("Queues", "", 59664, "GetText", $i, "0") $AgentTime = ControlListView("Queues", "", 59664, "GetText", $i, "1") If $AgentStatus <> "" Then FileWriteLine($hfile, $AgentStatus & ";" & $AgentTime) EndIf $AgentStatus = "" $AgentTime = "" $i = $i + 1 Until $i = $TotalAgents $i = 0 Do $DataQueue = ControlListView("Queues", "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", "0", $i) FileWriteLine($hfile, $DataQueue) $i = $i + 1 $DataQueue = "" Until $i = $TotalColumns FileClose($hfile) $i = 0 Sleep(5000) $TotalColumns = "" $TotalAgents = "" Until 2 = 1 Edited July 16, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
LucML Posted July 16, 2010 Author Share Posted July 16, 2010 You Rock!!! It's working. I didn’t understand well how the fileopen is working. Now I know for next time. Thanks a bunch Link to comment Share on other sites More sharing options...
KaFu Posted July 16, 2010 Share Posted July 16, 2010 You're welcome ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now