Jump to content

OnAutoItExitRegister and crash/task-kill


Recommended Posts

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

  • Developers
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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

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. 

Link to comment
Share on other sites

  • Developers
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

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

  • Developers

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...