Burgaud Posted June 25, 2020 Share Posted June 25, 2020 According to documentation: Quote There must be a TCPShutdown() call to avoid memory consumption. A script must call one TCPShutdown() call for every successful TCPStartup() call. Example() Func Example() TCPStartup() ; Start the TCP service. ; Register OnAutoItExit to be called when the script is closed. OnAutoItExitRegister("OnAutoItExit") EndFunc ;==>Example Func OnAutoItExit() TCPShutdown() ; Close the TCP service. EndFunc ;==>OnAutoItExit Here is my problem: When app exits, it has to call a TCPShutdown. BUT I never seen it doing a tcpshutdown when it app crashed or killed by taskmanager. Does that mean taskmanager and a crash circumvents the OnAutoItExit? Dan Link to comment Share on other sites More sharing options...
Developers Jos Posted June 25, 2020 Developers Share Posted June 25, 2020 11 minutes ago, Burgaud said: BUT I never seen it doing a tcpshutdown when it app crashed or killed by taskmanager. Which seems pretty obvious ...right, but why are you killing the task in stead of ending it nicely? 12 minutes ago, Burgaud said: Does that mean taskmanager and a crash circumvents the OnAutoItExit? Of course ... you are killing the process which means you simply stop it in whatever state it is in. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2020 Moderators Share Posted June 25, 2020 Burgaud, As I understand it, OnAutoItExit only functions during a normal, graceful exit from a script - as shown by the expected @exitMethod messages shown in the Help file. If the script crashes or is killed externally then the code will not run as the normal script shutdown process will not occur. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Burgaud Posted June 25, 2020 Author Share Posted June 25, 2020 Ok... I understand... Now for 2nd part of the problem: TCPShutdown per every TCPStartup. If script crashed or killed, how will that affect TCPShutdown? Am I correct to assume that this wont matter because autoit.exe terminated and the memory is released? Dan Link to comment Share on other sites More sharing options...
Nine Posted June 25, 2020 Share Posted June 25, 2020 24 minutes ago, Burgaud said: Am I correct to assume that this wont matter because autoit.exe terminated and the memory is released? Probably. But you could test it yourself by checking memory before start, run your program, crash it and look memory after. Do that a few times and come back to tell us if memory is released or not. “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...
Developers Jos Posted June 25, 2020 Developers Share Posted June 25, 2020 49 minutes ago, Burgaud said: f script crashed or killed, how will that affect TCPShutdown? Am I correct to assume that this wont matter because autoit.exe terminated and the memory is released? In general, any program that is killed, will not do any cleanup of memory and any open handles/files. I am not sure what you mean by crash in this case, but in case of a hard-crash the same counts. In case of a soft crash (read autoit3 error) the cleanup will be performed by AutoIt3 but there is still a good chance the TCP stuff isn't unless the TCPShutDown() is performed. So one really should never Kill tasks, unless they aren't responsive, otherwise you script should always terminate in a normal fashion. So again the question: Why does it seems like you use the kill task as a regular thing, or did I misunderstand that? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Burgaud Posted June 25, 2020 Author Share Posted June 25, 2020 39 minutes ago, Jos said: So again the question: Why does it seems like you use the kill task as a regular thing, or did I misunderstand that? Jos Honestly, I do not know Killing it is that bad. Thanks for this good info. Henceforth, will avoid it. The script does not have any GUI to "exit" it. So will add hotkey sequences to exit the script. PS. By crash I mean something like script encountering syntax error, or array subscript mismatch... etc... Dan Link to comment Share on other sites More sharing options...
Developers Jos Posted June 25, 2020 Developers Share Posted June 25, 2020 The script always had a gui in the background so you can always send a winclose to your script. 🙂 Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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