Jump to content

Memory logging

Recommended Posts


As relative beginner with AutoIT I got stuk with memory logging. I have created a script that starts some applications, runs some tests in these applications and then stops the applications. This procedure is cycled. Now I like to log the memory usage of these processes each cycle.

I found the function MemGetStats but don't know how to use it for logging the individual  processes. Who can help me further with this?

Share this post

Link to post
Share on other sites

as you can see by the example for MemGetStats, it writes the output to a msgbox.

#include <MsgBoxConstants.au3>
Local $aMem = MemGetStats()
MsgBox($MB_SYSTEMMODAL, "", "Total physical RAM (KB): " & $aMem[1])

instead of writing the output to a msgbox, write the output to a file using FileWrite. Look at the example and you will see how it is done.

Edited by Bert

Share this post

Link to post
Share on other sites
...how to use it for logging the individual  processes.​

It doesn't appear that MemGetStats allows you to collect stats for any particular process(es).  Check out _WinAPI_GetProcessMemoryInfo in the help file.

Share this post

Link to post
Share on other sites

Here is a piece of code, how I got it working:

local $aMemory = ProcessGetStats("FlucamViewer.exe")
        ConsoleWrite("Flucam_1 ; " & $aMemory[0] & " ;  " & "Flucam_2  ;" & $aMemory[1] & @CR)

    Local $aMem = MemGetStats()
    ConsoleWrite ("Memory load and physical RAM" & @CR & $aMem[0] & "; " & $aMem[2] & @CR)
    FileWriteLine($logFile_memtest, @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC & " : " & $aMem[0] & "  ;  " & $aMem[2] & "Memory load and physical RAM (" & $nrRestarts & ")")

Share this post

Link to post
Share on other sites


Where has your Google-Fu gone? FlucamViewer is used by those who have to deal with scanning electron microscopes - nothing untoward at all.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


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


Share this post

Link to post
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

  • Similar Content

    • Rammanan
      By Rammanan
      Hi all, Below is my script,
      Pls advise me if any wrong on that....File exit in location but the return -1.
      FileOpen($file, 0)
         $line = FileReadLine($file)
      Local $aArray = _FileListToArrayRec($serverpath, "*|*.txt", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_NOPATH)
      If @error Then
              MsgBox($MB_SYSTEMMODAL, "Ooops!", "No files found")
          ;_ArrayDisplay($aArray, "Sorted tree")
                 Local $hSearch = FileFindFirstFile($line)
    • Theodoor
      By Theodoor
      I am trying to use the ControlClick in a "save as"-window to select the path of where to save the document.
      I found out that when in press the icon in front of the path, i select the path. So I am trying to press that button (i have attached a print screen of this window).
      While trying to figure out how i had to use the ControlClick, it said somewhere that i could us Au3Info to find out what title,... i should use with the ControlClick.
      The result of the Au3Info I have attached aswel.
      The ControlClick that i tried are these: (and none of these even move the mouse)
      ControlClick("[CLASS:ToolbarWindow32; INSTANCE:4]", "", "", "Left" ,1 ,10,10)
      ControlClick("[CLASS:ToolbarWindow32; INSTANCE:4]", "", "1001", "Left" ,1 ,10,10)
      ControlClick("[CLASS:ToolbarWindow32]", "", "", "Left" ,1 ,10,10)
      ControlClick("Save project as", "", "", "Left" ,1 ,10,10)
      I don't know what I am doing wrong.
      Should I use a controlID? is my windowtitle wrong?
      Can anyone help me?
      Thanks in advance,

    • Mercy
      By Mercy
      I need to add a column with data daily at the end of the column and calculate the difference between last two columns in put it in a seperate column. So i need to get the  position of the last column.
      Local $count = $oWorkbook2.Worksheets(1).UsedRange.Columns.Count MsgBox(0,"",$count) ; ***************************************************************************** ; Copy a single cell from another workbook. Pass the source range as object. ; ***************************************************************************** Local $oRange = $oWorkbook2.Worksheets(1).Range("A1:A15") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange,"H1:H15") _Excel_RangeWrite($oWorkbook1, $oWorkbook1.Worksheets(1), "=C2-H2", "I2:I15", False) this code copies to a specific column H with a range 15. But i need to keep that column range to update automatically when columns are added.
    • Mercy
      By Mercy
      I inspect that Security tab in the webpage .I get the html element below:
      <td tabindex="-1" align="center" class="infaTabsetSimpleTabSetTop" nowrap="true" valign="middle" onfocus="app_details_browse.$47()">Security</td>
      If iam using the class name and trying to click the element. Iam getting "found" but cannot click as all the tab contains same class.
      If iam using the onfocus attribute which is different for every tab and trying to click the element, the element cannot be found.
      Local $oFound = "" Local $oBtns = _IETagNameGetCollection($oIE, "td") For $oBtn In $oBtns ;If String($oBtn.onfocus) ="app_details_browse.$47()" Then If String($oBtn.classname) = "infaTabsetSimpleTabSetTop" Then $oFound = $oBtn EndIf Next If IsObj($oFound) Then _IEAction ($oFound, "focus") _IEAction ($oFound, "click") MsgBox(16, "Success", "found") Else MsgBox(16, "Failed", "Not found.") EndIf

    • nacerbaaziz
      By nacerbaaziz
      I designed this code To help the blind
      Where screen readers users can  Identify the sefocus  item with audio files
      In this code i define some elements
      Unfortunately, I did not know how to define the other elements
      I am waiting for your initiative to  define the other elements
      Thank you in advance
      Global $CFocus = "" Func focus($window) Local $focusing = ControlGetFocus($window) Local $handle = ControlGetHandle($window, "", $focusing) If Not ($focusing = $CFocus) Then Switch StringTrimRight($focusing, 1) Case "button" If IsCheckBox($handle) Then play("checkBox") ElseIf IsRadio($handle) Then play("RadioButton") Else play("focus") EndIf $CFocus = $focusing Case "comboBox", "ListBox" play("list") $CFocus = $focusing Case "edit", "input" play("edit") $CFocus = $focusing Case Else play("focus") $CFocus = $focusing EndSwitch EndIf EndFunc ;==>focus Func IsCheckBox($ctrl_hwnd) $Style = _WinAPI_GetWindowLong($ctrl_hwnd, $GWL_STYLE) Return BitAND($Style, $BS_CHECKBOX) = $BS_CHECKBOX EndFunc ;==>IsCheckBox Func IsRadio($ctrl_hwnd) $Style = _WinAPI_GetWindowLong($ctrl_hwnd, $GWL_STYLE) Return BitAND($Style, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON EndFunc ;==>IsRadio Func play($name, $wait = 0) Local Const $SND_RESOURCE = 0x00040004 Local Const $SND_ASYNC = 1 ; Play the file - the script will pause as it sounds If $wait = 0 Then DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", BitOR($SND_RESOURCE, $SND_ASYNC)) Else DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE) EndIf Return 1 EndFunc ;==>play  

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.