mitchell12388 Posted January 26, 2019 Share Posted January 26, 2019 I would like to start by saying that I have no training in any sort of coding i taught myself bat files then several years ago I was attempting to do something more complex with a bat that's how I found Autoit. that being said please don't make to much fun of me if this code is just ridiculous. I believe the "program" is using to much memory for what it is so I decided to create a forum account to ask about it. Thanks in advance! #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=NL.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Fileversion=1.3.0.3 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_Run_Tidy=y #AutoIt3Wrapper_Tidy_Stop_OnError=n #AutoIt3Wrapper_Run_Au3Stripper=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("TrayAutoPause", 0) If FileExists("C:\NetLog") = 0 Then DirCreate("C:\Netlog") EndIf While 1 $b = "NA" $a = Ping("1.1.1.1") FileOpen("C:\NetLog\Net " & @MON & "-" & @MDAY & "-" & @YEAR & ".txt", 1) If $a = 0 Then $b = Ping("8.8.8.8") If $b = 0 Then FileWriteLine("C:\NetLog\Net " & @MON & "-" & @MDAY & "-" & @YEAR & ".txt", "FAILED " & @MON & "-" & @MDAY & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) EndIf Else FileWriteLine("C:\NetLog\Net " & @MON & "-" & @MDAY & "-" & @YEAR & ".txt", "MS: A=" & $a & " B=" & $b & " " & @MON & "-" & @MDAY & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) EndIf FileClose("C:\NetLog\Net " & @MON & "-" & @MDAY & "-" & @YEAR & ".txt") Sleep(60000) WEnd Link to comment Share on other sites More sharing options...
Nine Posted January 26, 2019 Share Posted January 26, 2019 Why and How do you say or know it is taking too much memory ? Do you think there is memory leak ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 Just seems high for the simplicity of the program Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 mine has been running for 2 weeks solid could that be the cause? Link to comment Share on other sites More sharing options...
Nine Posted January 26, 2019 Share Posted January 26, 2019 Just now, mitchell12388 said: mine has been running for 2 weeks solid could that be the cause? nope mitchell12388 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 Autoit just doesn't like me... LOL! Link to comment Share on other sites More sharing options...
Nine Posted January 26, 2019 Share Posted January 26, 2019 1 minute ago, mitchell12388 said: Autoit just doesn't like me... LOL! nope again. But if you want us to give you a better advice, I suggest you should provide a full detail of your system config. How did you compile it... etc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 Sorry this is my first time ever asking for help on a forum would a speccy report and screenshots of the compiling options be sufficient? Link to comment Share on other sites More sharing options...
Nine Posted January 26, 2019 Share Posted January 26, 2019 Version of OS. Version of autoit. Version of Scite. Try a simple x86 compile with right click. See if that makes a difference. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 Windows 7 X64 Autoit 3 SciTE-Lite Version 3.5.4 and before I recompiled i wanted to check so i closed the instance that had been up for 14 days and ran from my old .exe started with 3684K Link to comment Share on other sites More sharing options...
Nine Posted January 26, 2019 Share Posted January 26, 2019 AutoIt (Latest Stable Version) v3.3.14.5 When running your script with x86, I am at 1827 k. Also using win7 x64 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 I hadn't compiled at x86 since i noticed that difference i waited for your response. before stopping again it was at 5,068 K so i now found the full version in my help file v3.3.14.5 and this was after I right clicked and compiled for x86 Link to comment Share on other sites More sharing options...
TheXman Posted January 26, 2019 Share Posted January 26, 2019 (edited) The reason your memory keeps rising is because you are creating a new file handle with each iteration through your loop. FileOpen returns a handle to your file. That handle is used by the FileClose. Your FileClose was failing because it expected, as its parameter, the handle created by the FileOpen, not a file name. If you were going to use FileOpen, then your FileWriteLine functions should have been using the file handle, not the file name. I know that it can be a little confusing when you are first starting out. Your script is only writing to the file once every 60 seconds. So you can just let the FileWriteLine open and close the file automatically by supplying the file name instead of a handle (like you were already doing). Change your script to something like this and see if the memory keeps creeping up or not. Also, I modified the logic to only create the date and time values once per iteration. I left the rest of the logic alone. Opt("TrayAutoPause", 0) If FileExists("C:\NetLog\") = 0 Then DirCreate("C:\Netlog") EndIf While 1 $dt = @MON & "-" & @MDAY & "-" & @YEAR $hms = @HOUR & ":" & @MIN & ":" & @SEC $b = "NA" $a = Ping("1.1.1.1") If $a = 0 Then $b = Ping("8.8.8.8") If $b = 0 Then FileWriteLine("C:\NetLog\Net " & $dt & ".txt", "FAILED " & $dt & " " & $hms) EndIf Else FileWriteLine("C:\NetLog\Net " & $dt & ".txt", "MS: A=" & $a & " B=" & $b & " " & $dt & " " & $hms) EndIf Sleep(60000) WEnd If you wanted to use the FileOpen way of doing things, then it would look something like this: Opt("TrayAutoPause", 0) If FileExists("C:\NetLog") = 0 Then DirCreate("C:\Netlog") EndIf While 1 $dt = @MON & "-" & @MDAY & "-" & @YEAR $hms = @HOUR & ":" & @MIN & ":" & @SEC $b = "NA" $a = Ping("1.1.1.1") $hFile = FileOpen("C:\NetLog\Net " & $dt & ".txt", 1) If $a = 0 Then $b = Ping("8.8.8.8") If $b = 0 Then FileWriteLine($hFile, "FAILED " & $dt & " " & $hms) EndIf Else FileWriteLine($hFile, "MS: A=" & $a & " B=" & $b & " " & $dt & " " & $hms) EndIf FileClose($hFile) Sleep(60000) WEnd Edited January 26, 2019 by TheXman Xandy and mitchell12388 1 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 Nothing was failing this was working great the way it was it was just using more memory that i thought it should! Link to comment Share on other sites More sharing options...
mitchell12388 Posted January 26, 2019 Author Share Posted January 26, 2019 1 hour ago, TheXman said: Your FileClose was failing because it expected, as its parameter, the handle created by the FileOpen, not a file name. Sorry I meant to quote this in my last post... also thanks That first script you posted looks much cleaner 1 hour ago, TheXman said: Opt("TrayAutoPause", 0) If FileExists("C:\NetLog\") = 0 Then DirCreate("C:\Netlog") EndIf While 1 $dt = @MON & "-" & @MDAY & "-" & @YEAR $hms = @HOUR & ":" & @MIN & ":" & @SEC $b = "NA" $a = Ping("1.1.1.1") If $a = 0 Then $b = Ping("8.8.8.8") If $b = 0 Then FileWriteLine("C:\NetLog\Net " & $dt & ".txt", "FAILED " & $dt & " " & $hms) EndIf Else FileWriteLine("C:\NetLog\Net " & $dt & ".txt", "MS: A=" & $a & " B=" & $b & " " & $dt & " " & $hms) EndIf Sleep(60000) WEnd I'll have to give it a try it's not copyright?? 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