Jump to content

AutoIt causes memory leak?


Yaerox
 Share

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
Link to comment
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.

Link to comment
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? ^^

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

Link to comment
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)

Link to comment
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
Link to comment
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.

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...