Jump to content

Howto track down, why a script is freezing (long run)


rudi
 Share

Recommended Posts

Hi,

any suggestion to track down, why a script is freezing after a longer run time?

This is a general question, I've checked the common mistakes, I've made so far (inside a loop doing fileopen() without fileclose(), runwait() for progs, that don't terminate, infinite recursive loops etc.)

 

This script stops just after several days of running...

Is  there a direct way to "count" the amount of MEM and handles, a autoit script is using itself, or by child processes?

 

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Moderators

rudi,

Adding Opt("TrayIconDebug", 1) at the top of the script will tell you where the script has paused, which might give you valuable pointers to where the problem lies.

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

Hi,

the script is quite long, so I'll attach it.

TrayIconDebug in this case doesn't help, as this is a Windows installation to operate a industrial machine, there is just a web GUI covering all of the screen, no task bar, so no systray.

 

Main script: tshark-D-und-Ringbuffer-alle-NICs.au3

2nd, external script: SNMP-OID-auslesen.au3, using SNMP_UDF_v1.7.3.au3 (UDF from this site)

 

The script is using TSHARK.EXE -D to get all local NICs

Then it's looking for a local disk to save the trace files to and starts capturing to a ring buffer on all found NICs

Then it's placing a minimal GUI to indicate by one single button, when the operator of the machine is facing issues, that might be LAN related. when the button is pressed, the 2nd script is launched to read some OID values from  the switches, listed in the INI file. "@" is replaced by [1..8] = the number of ports of the used switches.

 

Regards, Rudi.

tbe-tshark-scrip-hang-autoit-forums.zip

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hello Earthshine,

to know, what's in a ZIP file, just look into it :bye: that never ever harms ;)

In that ZIP file there are are exactly the sources you ask for, on top the Win-Unix-Tooltail.exe, as well as a URL to download wireshark. That's all required to exactly redo the required environment to run my scripts. If you don't like that tail, pick one from google. And wireshark is obviously pointing towards the offical download site for wireshark.

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

I recommend to add to your program option for logging to file.

In INI add option Logging=1

And in program at important places add writing important states to LOG file.

After crash/freeze of your program you will see at the end of LOG file, where was problem just before hanging.

Here is example:

$ini_logging = IniRead($ini, "Setup", "Logging", "0")
If $ini_logging == '1' Then $log = @ScriptDir & '\' & StringReplace(@ScriptName,'.exe','.log')

; your program ...

_Log('')

...
$A = ...
_Log('start: var A=' & $A)
...

Func _Log($text)
    If $ini_logging == '1' Then
        If Not($text == '') Then $text = @YEAR & '-' & @MON & '-' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & '.' & @MSEC & ': ' & $text
        FileWrite($log, $text & @CRLF)
    EndIf
EndFunc

 

Link to comment
Share on other sites

@Zedna

 

I'll give it a try, thx.

A way to check, what a script itself is "consuming" is possibly available as well? (RAM, Handles, CPU usage, nested-loop-deepth, ...)

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

for professional logging look no further than log4a.au3 found in the samples forum. and do this in the main AU3 file, all others just include the log4a.au3

 

#include 'log4a.au3'


#Region ;**** Logging ****
; Enable logging and don't write to stderr
_log4a_SetEnable()
; Write to stderr, set min level to warn, customize message format
_log4a_SetErrorStream()
_log4a_SetCompiledOutput($LOG4A_OUTPUT_FILE)
_log4a_SetMinLevel($LOG4A_LEVEL_DEBUG)
; If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled
_log4a_SetFormat("${date} | ${host} | ${level} | ${message}")
#EndRegion ;**** Logging ****

In that configuration, the logger will log to your Editor output window, if compiled it creates a log file automatically with the script name. you can set your own minimum levels and stuff.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

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

×
×
  • Create New...