Jump to content
Sign in to follow this  
Yaerox

AutoIt causes memory leak?

Recommended Posts

Hey guys,

im writing on my project and got some memory leaks. Actual im looking for the leak for a month and now i got some curios results.

I wrote some testscripts, to see, if AutoIt causes memory leaks. So i wrote some testscript for Listviews, Lists, and Labels to see, if i create a Listview with lets say 1000 items and delete them, does AutoIt reset the complete memory of these items? i'd say no. I did some tests and got the result that in best case 4K memory is missing ...

Testscript #1: Listview created by nature func in combination with UDF funcs to create and delete items.

#include
#include
#include

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Local $hGUI = GUICreate("GUI", 500, 500)
Local $hListview = GUICtrlCreateListView("Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

While 1
Sleep(100)
WEnd

Func _create_items()
For $i = 0 To 100
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
EndFunc

Func _delall_items()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListview))
EndFunc

Func _exit()
Exit
EndFunc

Testscript #2: Listview created by UDFfunc in combination with UDF funcs to create and delete items.

#include
#include
#include

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Local $hGUI = GUICreate("GUI", 500, 500)
local $hListview = _GUICtrlListView_Create($hGUI, "Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")


While 1
Sleep(100)
WEnd

Func _create_items()
For $i = 0 To 100
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
EndFunc

Func _delall_items()
_GUICtrlListView_DeleteAllItems($hListview)
EndFunc

Func _exit()
Exit
EndFunc

Testscript #3: Creating a list

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Local $hGUI = GUICreate("GUI", 500, 500)
Local $hList = GUICtrlCreateList("Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

While 1
Sleep(100)
WEnd

Func _create_items()
For $i = 0 To 100
GUICtrlSetData($hList, Random(0, 2000))
Next
EndFunc

Func _delall_items()
GUICtrlSetData($hList, "")
EndFunc

Func _exit()
Exit
EndFunc

Testscript #4: Working with labels.

#include
#include
#include

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Local $hGUI = GUICreate("GUI", 500, 500)
Local $hlabel = GUICtrlCreateLabel("AP's: ", 10, 45, 100, 440)
Local $hlabel2 = GUICtrlCreateLabel("AP's: ", 110, 45, 100, 440)
Local $hlabel3 = GUICtrlCreateLabel("AP's: ", 210, 45, 100, 440)
Local $hlabel4 = GUICtrlCreateLabel("AP's: ", 310, 45, 100, 440)
Local $hlabel5 = GUICtrlCreateLabel("AP's: ", 410, 45, 100, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

While 1
Sleep(100)
WEnd

Func _create_items()
Local $sMsg = ""
Local $sMsg2 = ""
Local $sMsg3 = ""
Local $sMsg4 = ""
Local $sMsg5 = ""

For $i = 0 To 30
$sMsg = $sMsg & Random(1,200) & @CR
$sMsg2 = $sMsg2 & Random(1,200) & @CR
$sMsg3 = $sMsg3 & Random(1,200) & @CR
$sMsg4 = $sMsg4 & Random(1,200) & @CR
$sMsg5 = $sMsg5 & Random(1,200) & @CR
Next

GUICtrlSetData($hlabel, $sMsg)
GUICtrlSetData($hlabel2, $sMsg2)
GUICtrlSetData($hlabel3, $sMsg3)
GUICtrlSetData($hlabel4, $sMsg2)
GUICtrlSetData($hlabel5, $sMsg3)
EndFunc

Func _delall_items()
GUICtrlSetData($hlabel, "")
GUICtrlSetData($hlabel2, "")
GUICtrlSetData($hlabel3, "")
GUICtrlSetData($hlabel4, "")
GUICtrlSetData($hlabel5, "")
EndFunc

Func _exit()
Exit
EndFunc

Got someone a statements for me, if its true?

Regards

Looked up here: http://www.google.com

(Also tried to find out if ShellExecute causes problems)

and some more...

Edited by MikeWenzel

Share this post


Link to post
Share on other sites

Workaround: you can free the process memory after deleting some items.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Func _SelfReduceMemory()
     DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
EndFunc   ;==>_SelfReduceMemory


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Garbage Collector ... since the following post, im a bit scared of using EmptyWorkingSet ...

ReduceMemory doesn't reduce the memory used, it just pages it to the hard drive, so it's an artificial reduction in memory. Calling it every 5 seconds is pointless, figure out where your memory leak is coming from before you start trying to find workarounds to bad code.

It's like you're building a house on mud, every day it sinks a little bit more unless you jack it up, you're not fixing the problem you're just fixing the symptom, the house is still sinking only you don't see that it's happening anymore. Out of sight out of mind is not good coding practice.

Share this post


Link to post
Share on other sites

Bad workaround then.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I mean for me it looks like where you want to use it. On this Testscripts ofc it works well, but e.g. i got a memory leak on my project, the reason why i looked up if Listviews are leaking, im running my script 24/7. With Garbage Collector its still rising i think, it just needs more time. So ... :/ im still working around too, maybe someone else got an idea? ^^

Share this post


Link to post
Share on other sites

No, this was a workaround for high memory, but not for memory leak.

e.g : I load a 1mib db on an array, the process takes 70mib of memory; after reducing the memory I have 3mib.

I doubt that devs forgot to delete an object/release a ressource in the functions you are using; but AutoIt is not perfect.

Edit : for your label examples, you are not deleting labels, you are just editing it's content which is not significant.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

But e.g. on my label_script, why the memory usage isnt going back after clicking the _delall_items button? In my opinion there have to be a way to free the memory ...

I said: "i got a memory leak on my project" but i meant, everyone is telling me i had a memory leak because my memory is rising. I think its an AutoIt mistake, therefore my testscripts ...

#Edit: If you use the Testscript #1 and create 4000 Items, Delete them waiting and looking whats up with your memory, you can see that virtual memory is rising then ... i think this DllCall can hold down memory, but its no solution for this maybe existing problem of AutoIt :/

Edited by MikeWenzel

Share this post


Link to post
Share on other sites

Well, I would say you've already got the answer in your initial post:

It seems to me that the standard functions use the lparam parameter to store a pseudo controlid (I've always wondered how that is done :) ). So the functions are good for quick coding, but not so good for 24/7 code. As Rover said, use the UDF functions for Listview and the mem leak should be gone.

Edit:

Adjusted your example #2 a bit and everything seems fine to me.

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Local $hGUI = GUICreate("GUI", 500, 500)
Local $hListview = _GUICtrlListView_Create($hGUI, "Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)
GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
for $i = 0 to 100
_create_items()
Sleep(1000)
_delall_items()
Next
While 1
Sleep(100)
WEnd
Func _create_items()
_GUICtrlListView_BeginUpdate($hListview)
For $i = 0 To 10000
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_create_items
Func _delall_items()
_GUICtrlListView_BeginUpdate($hListview)
_GUICtrlListView_DeleteAllItems($hListview)
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_delall_items
Func _exit()
Exit
EndFunc ;==>_exit

Edit #2:

Nevertheless the mem leak in the default function is definitly worth a bug ticket!

Edit #3:

Here's a little more aggressive example. I've added _GUICtrlListView_SetItemCount($hListview, 0), as this was suggested to be used explicitly in some google results.

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Local $hGUI = GUICreate("GUI", 500, 500)
Local $hListview = _GUICtrlListView_Create($hGUI, "Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 100 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)
GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
For $i = 1 To 10000
ConsoleWrite($i & @CRLF)
_create_items()
_delall_items()
Next
While 1
Sleep(100)
WEnd

Func _create_items()
_GUICtrlListView_BeginUpdate($hListview)
_GUICtrlListView_SetItemCount($hListview, 100)
For $i = 1 To 100
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_create_items
Func _delall_items()
_GUICtrlListView_BeginUpdate($hListview)
_GUICtrlListView_DeleteAllItems($hListview)
_GUICtrlListView_SetItemCount($hListview, 0)
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_delall_items
Func _exit()
Exit
EndFunc ;==>_exit
Edited by KaFu

Share this post


Link to post
Share on other sites

Did it this way:

#include
#include

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Local $hGUI = GUICreate("GUI", 500, 500)
Local $hListview = _GUICtrlListView_Create($hGUI, "Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 10000 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

;~ For $i = 0 To 100
;~ _create_items()
;~ Sleep(1000)
;~ _delall_items()
;~ Next

While 1
Sleep(100)
WEnd

Func _create_items()
_GUICtrlListView_BeginUpdate($hListview)
For $i = 0 To 10000
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_create_items

Func _delall_items()
_GUICtrlListView_BeginUpdate($hListview)
_GUICtrlListView_DeleteAllItems($hListview)
_GUICtrlListView_EndUpdate($hListview)
EndFunc ;==>_delall_items

Func _exit()
Exit
EndFunc ;==>_exit

My Result:

11.228K start

12.852K clicked create once

11.600K clicked del

11.500K (waited a few mins)

12.760K clicked create once

11.736K clicked create once

12.784K clicked create once

11.648K clicked create once

15.998K clicked create 3 times

12.132K clicked create once

Edited by MikeWenzel

Share this post


Link to post
Share on other sites

Hmmm, mem leaks are sometime hard to detect, doing some few manual tests are imho not sufficient. Maybe give my second example a try, increase the loop count to 100.000 and see how mem usage develops over a longer time (esp. the setitemcount might have an effect too).

Edit:

100 16.648

1000 16.972

3000 16.972

4000 16.972

5000 16.972

7000 16.976

9000 16.976

10000 16.972

19000 16.996

26000 17.032

30000 17.032

50000 17.036

63000 17.040

100000 17.040

Well, mem usage is increasing slighlty over time, but I would not say this is really a mem leak.

Edited by KaFu

Share this post


Link to post
Share on other sites

Did it with your script - loop count to 100, now starting a second try with 100000 too...

Edited by MikeWenzel

Share this post


Link to post
Share on other sites

Mike,

The following might be usefull as a template to measure mem resource usage, varying the controls as you like. It is setup to run the control add/delete every 3 seconds and report memory usage every 10 seconds.

Use the ESC key to exit.

#include <guiconstants.au3>
#include <windowsconstants.au3>
#include <guilistview.au3>
#include <winapiex.au3>
#include <date.au3>

local $gui010   =   guicreate('ListView Mem Test - UDF')
local $aSize    =   wingetclientsize($gui010)
local $lst010   =   _GUICtrlListView_Create($gui010,'Test',0,0,$aSize[0],$aSize[1])
                    guisetstate()

                    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
                    adlibregister('_excercise',3000)
                    adlibregister('_logmem',10000)

local $fl_name = @scriptdir & 'memstats.txt'

_logmem()   ; memory usage at start

while 1
    switch guigetmsg()
        case $gui_event_close
            Exit
    EndSwitch
WEnd

func _excercise()

    for $1 = 0 to 9999
        _GUICtrlListView_AddItem($lst010,'Entry # ' & $1)
    Next

    _GUICtrlListView_DeleteAllItems($lst010)

EndFunc

func _logmem()

    local $hfl = fileopen($fl_name,1)
    if $hfl = -1 then msgbox(0,'Memstats File Open Error','File Name = ' & $fl_name)

    local $aMem = _winapi_getprocessmemoryinfo()

    filewrite($hfl, _now() & stringformat( _
                        'Page faults  = %010i ' & _
                        'Peak WS Size = %010i ' & _
                        'Current WS Size = %010i '  & _
                        'Peak Page Pool Usage = %010i '  & _
                        'Cur Page Pool Usage = %010i '  & _
                        'Peak non-Paged Pool Usage = %010i '  & _
                        'Cur non-Paged Pool Usage = %010i '  & _
                        'Cur Page file Alloc = %010i '  & _
                        'Peak Page file Alloc = %010i '  & _
                        'Current Private Space = %010i ' _
                        , $aMem[0], $aMem[1], $aMem[2], $aMem[3], $aMem[4], $aMem[5], $aMem[6], $aMem[7], $aMem[8], $aMem[9]) & @lf)

    fileclose($hfl)
    $hfl = 0

endfunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
     If BitAND($wParam, 0x0000FFFF) =  2 then exit
 EndFunc

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

"ReduceMemory doesn't reduce the memory used, it just pages it to the hard drive"

1) I am not qualified to disagree with BrewManNH

2) I am running xpsp3 with no paging

3) empty working set (ReduceMemory) works fine for me. --Shows in process manager & in speed of large ram-sucking processes

I have over-used 'ReduceMemory' & got diminished benifits (near zero) with abuse. Monoceres feels it causes trouble with angels (if abused).

If ReduceMemory only sends the mem page to hard drive, then why does it work so nicely with no paging?

I think that it is a good thing to have (ReduceMemory) at the beginning (only) of a script.

4) refer to .... 1)

Share this post


Link to post
Share on other sites

Fist of all sry for my late answer, i had no chance to work on it at the Weekend.

@KaFu: Script started on Friday around ~12MB Private Space. After 100.000 loops, the Private Space (today) was around ~14MB ...

@kylomas: Thanks alot for this script. I was looking for it for two weeks :P Did this on your Script (modified a bit):

#include
#include
#include
#include
#include

local $gui010 = guicreate('ListView Mem Test - UDF')
local $aSize = wingetclientsize($gui010)
local $lst010 = _GUICtrlListView_Create($gui010,'Test',0,0,$aSize[0],$aSize[1])
guisetstate()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
adlibregister('_excercise',3000)
adlibregister('_logmem',10000)

local $fl_name = @scriptdir & 'memstats.txt'

_logmem() ; memory usage at start

while 1
switch guigetmsg()
case $gui_event_close
AdlibUnRegister('_excercise')
AdlibUnRegister('_logmem')
Sleep(3000)

$aMem = 0
_logmem() ; memory usage at end
Exit
EndSwitch
WEnd

func _excercise()

for $1 = 0 to 9999
_GUICtrlListView_AddItem($lst010,'Entry # ' & $1)
Next

_GUICtrlListView_DeleteAllItems($lst010)

EndFunc

func _logmem()

local $hfl = fileopen($fl_name,1)
if $hfl = -1 then msgbox(0,'Memstats File Open Error','File Name = ' & $fl_name)

local $aMem = _winapi_getprocessmemoryinfo()

filewrite($hfl, "[" & _now() & "] " &stringformat( _
'Page faults = %010i ' & _
'Peak WS Size = %010i ' & _
'Current WS Size = %010i ' & _
'Peak Page Pool Usage = %010i ' & _
'Cur Page Pool Usage = %010i ' & _
'Peak non-Paged Pool Usage = %010i ' & _
'Cur non-Paged Pool Usage = %010i ' & _
'Cur Page file Alloc = %010i ' & _
'Peak Page file Alloc = %010i ' & _
'Current Private Space = %010i ' _
, $aMem[0], $aMem[1], $aMem[2], $aMem[3], $aMem[4], $aMem[5], $aMem[6], $aMem[7], $aMem[8], $aMem[9]) & @lf)

fileclose($hfl)
$hfl = 0

endfunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
If BitAND($wParam, 0x0000FFFF) = 2 Then
AdlibUnRegister('_excercise')
AdlibUnRegister('_logmem')
Sleep(3000)
$aMem = 0
_logmem() ; memory usage at end
Exit
EndIf
EndFunc

And got:

[17.12.2012 08:33:17] Page faults = 0000007107 Peak WS Size = 0027602944 Current WS Size = 0027602944 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013272 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0021643264 Peak Page file Alloc = 0021643264 Current Private Space = 0021643264
[17.12.2012 08:33:29] Page faults = 0000008163 Peak WS Size = 0029724672 Current WS Size = 0028573696 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0022671360 Peak Page file Alloc = 0023478272 Current Private Space = 0022671360
[17.12.2012 08:33:41] Page faults = 0000009264 Peak WS Size = 0029753344 Current WS Size = 0028733440 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0022966272 Peak Page file Alloc = 0023478272 Current Private Space = 0022966272
[17.12.2012 08:33:53] Page faults = 0000010395 Peak WS Size = 0030113792 Current WS Size = 0028999680 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0023109632 Peak Page file Alloc = 0024330240 Current Private Space = 0023109632
[17.12.2012 08:34:05] Page faults = 0000011583 Peak WS Size = 0030851072 Current WS Size = 0029782016 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0024236032 Peak Page file Alloc = 0024907776 Current Private Space = 0024236032
[17.12.2012 08:34:17] Page faults = 0000012613 Peak WS Size = 0031072256 Current WS Size = 0029913088 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000013272 Cur Page file Alloc = 0023924736 Peak Page file Alloc = 0025169920 Current Private Space = 0023924736
[17.12.2012 08:34:29] Page faults = 0000013563 Peak WS Size = 0031072256 Current WS Size = 0030044160 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000201920 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012128 Cur Page file Alloc = 0024657920 Peak Page file Alloc = 0025169920 Current Private Space = 0024657920
[17.12.2012 08:34:41] Page faults = 0000014452 Peak WS Size = 0031072256 Current WS Size = 0029818880 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0023719936 Peak Page file Alloc = 0025169920 Current Private Space = 0023719936
[17.12.2012 08:34:53] Page faults = 0000015385 Peak WS Size = 0031072256 Current WS Size = 0030056448 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0024465408 Peak Page file Alloc = 0025169920 Current Private Space = 0024465408
[17.12.2012 08:35:05] Page faults = 0000016295 Peak WS Size = 0031072256 Current WS Size = 0030027776 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0024199168 Peak Page file Alloc = 0025169920 Current Private Space = 0024199168
[17.12.2012 08:35:17] Page faults = 0000017258 Peak WS Size = 0031072256 Current WS Size = 0029904896 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0023941120 Peak Page file Alloc = 0025169920 Current Private Space = 0023941120
[17.12.2012 08:35:29] Page faults = 0000018244 Peak WS Size = 0031117312 Current WS Size = 0030306304 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0024256512 Peak Page file Alloc = 0025169920 Current Private Space = 0024256512
[17.12.2012 08:35:36] Page faults = 0000018499 Peak WS Size = 0031195136 Current WS Size = 0030466048 Peak Page Pool Usage = 0000203480 Cur Page Pool Usage = 0000185720 Peak non-Paged Pool Usage = 0000013752 Cur non-Paged Pool Usage = 0000012008 Cur Page file Alloc = 0024428544 Peak Page file Alloc = 0025169920 Current Private Space = 0024428544

We can see, Private Space is rising, and thats exactly my actual problem. Usually this should be the same as at the beginning if the complete memory is getting free. Doesnt it?

Regards

#Edit: @trancexx: maybe this can show my issue:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Add_Constants=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include
#include
#include
#include

Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

local $fl_name = @scriptdir & 'lv_test_memstats.txt'
Local $hGUI = GUICreate("GUI", 500, 500)
local $hListview = _GUICtrlListView_Create($hGUI, "Column 1", 10, 50, 480, 440)
Local $hButton1 = GUICtrlCreateButton("Create 4000 Items", 10, 10, 100, 30)
Local $hButton2 = GUICtrlCreateButton("Delete All Items", 120, 10, 100, 30)

GUISetState(@SW_SHOW, $hGUI)
GUICtrlSetOnEvent($hButton1, "_create_items")
GUICtrlSetOnEvent($hButton2, "_delall_items")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

_logmem("Begin Script")

While 1
Sleep(100)
WEnd

Func _create_items()
_logmem("Begin _Create_items")
For $i = 0 To 4000
_GUICtrlListView_AddItem($hListview, Random(0, 2000))
Next
_logmem("End _Create_items")
EndFunc

Func _delall_items()
_logmem("Begin _delall_items")
_GUICtrlListView_DeleteAllItems($hListview)
_logmem("End _delall_items")
EndFunc

func _logmem($sPos)
local $hfl = fileopen($fl_name,1)
if $hfl = -1 then msgbox(0,'Memstats File Open Error','File Name = ' & $fl_name)

local $aMem = _winapi_getprocessmemoryinfo()

filewrite($hfl, $sPos & " [" & _now() & "] " &stringformat( _
'Current Private Space = %010i ' _
, $aMem[0], $aMem[1], $aMem[2], $aMem[3], $aMem[4], $aMem[5], $aMem[6], $aMem[7], $aMem[8], $aMem[9]) & @lf)

fileclose($hfl)
$hfl = 0
endfunc

Func _exit()
_logmem("End Script")
Exit
EndFunc

[1]Begin Script [17.12.2012 09:13:46] Current Private Space =    7142
    [2]-----------------------------------------------------------------------------
    [3]Begin _Create_items [17.12.2012 09:13:48] Current Private Space = 7234
    [4]End _Create_items [17.12.2012 09:13:49] Current Private Space = 7395
    [5]Begin _delall_items [17.12.2012 09:13:50] Current Private Space = 7396
    [6]End _delall_items [17.12.2012 09:13:50] Current Private Space = 7396
    [7]Begin _Create_items [17.12.2012 09:13:51] Current Private Space = 7397
    [8]End _Create_items [17.12.2012 09:13:52] Current Private Space = 7528
    [9]Begin _delall_items [17.12.2012 09:13:52] Current Private Space = 7530
    [10]End _delall_items [17.12.2012 09:13:52] Current Private Space = 7530
    [11]Begin _Create_items [17.12.2012 09:13:57] Current Private Space = 7530
    [12]End _Create_items [17.12.2012 09:13:58] Current Private Space = 7636
    [13]Begin _delall_items [17.12.2012 09:13:58] Current Private Space = 7636
    [14]End _delall_items [17.12.2012 09:13:58] Current Private Space = 7636
    [15]-----------------------------------------------------------------------------
    [16]End Script [17.12.2012 09:14:03] Current Private Space = 7637

In my opinion the Private Space @line 6 should be the same as @line 3, doesnt it? Same @line 10 / 7, 14 / 11.

Edited by MikeWenzel

Share this post


Link to post
Share on other sites

When using Scite (I'm not sure whether it is this or AutoIt itself) , it keeps growing its memory needs as long as Scite stays active - no matter whether a program gets closed there or not.

Because I use a lot of ConsoleWrite() calls for debugging purposes, I always assumed that the amount of text displayed (and therefore stored) is the main culprit for loss of available memory.

Like all the results from ConsoleWrite() never get erased until the program gets closed ... even in compiled *.exe s as far as I can tell.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SteveJM
      When I use DllStructCreate() to reserve a chunk of memory I would like to know if I can rely on that memory being initialized to zero. Experience suggests that it is, but I have been searching to try and find a definitive statement anywhere that this is the case. I apologise if I have missed somewhere. Part of the reason for this question is so that my next search (after my personal memory has dimmed) should yield a link to this post, hopefully with an answer.
      A number of DLLs I use have structs where a few parts have to be explicitly set and other parts are reserved with the instruction that they must be set to zero. Because DllStructCreate() appears to zero-initialise the memory, I tend to forget to do it explicitly and everything seems to work. I am wondering whether I have been lucky and am storing up trouble for myself. It seems likely that the OS has been asked for zeroed memory, but without a promise in the documentation for DllStructCreate(),  perhaps that could change? Perhaps the developers wish to reserve the right to change their minds?
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By JuanFelipe
      Hello guys!
      I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.
       
      <td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>  
      Previously I used this code and it worked, but now it does nothing
      $botonconsulta = _IEGetObjByName($oIE,"Buscar") _IEAction($botonconsulta, 'click') _IELoadWait($oIE)  
      Now I have tried the following codes but none works.
       
      ;==================== 1 _IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');") ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") _IELoadWait($oIE) ;==================== 2 $forma = $oIE.document.obtenercasosPersonaPorDocumento $oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");") _IELoadWait($oIE) ;==================== 3 $boton = _IEGetObjById($oIE, "Buscar") $boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript") I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.
      function enviarForma(frm,tipoForma){ var bExisteDatoConsulta = false; var bError=true; var mensajeError=""; switch (tipoForma) { //--Forma documento case "0": if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) { if (!isNum(frm.numeroDocumento.value)) { bError = false; mensajeError += "El número de documento debe ser un valor numérico\n"; } bExisteDatoConsulta = true; } else { mensajeError += "Debe digitar un número de documento\n"; } break;  Thanks!
    • By Gowrisankar
      Dear members of the forum,
      I'm working on a project in which I have to use Image recognition technique. 
      Due to client restrictions, I couldn't use AutoIt for this project. 
      Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result? 
      I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
      Any guidance is deeply appreciated.
×
×
  • Create New...