Jump to content

Memory usage with FileOpenDialog


Recommended Posts

I have a script and I use FileOpenDialog to let the user select a file(.ini) and the items(Section Names) is then made into an Array. I noticed everytime I use this command it adds 500KB to Memory usage in Task Manager. I since thought that I was making the Arrays too large and using the memory that way but I added ArrayDelete before creating a new Array. I also did several trails blocking several parts of the script until I narrowed it down to FileOpenDialog being the culprate.

Below is the part of the script that keeps increasing the Memory usage:

File structure = AutoIt.exe\Parts\PartNumber.ini

Func Open()
    $search = FileFindFirstFile(@ScriptDir & "\Parts\*.ini")
    If $search = -1 Then
        FileClose($search)
        MsgBox(32, "Error", "No Part.ini's Found please make one!")
        Return(1)
    Else
        FileClose($search)
        $FullPath =  FileOpenDialog("Select Tool Info", @ScriptDir & "\Parts\", "Tool Info (*.ini)", 1)
        $Path = StringTrimRight($FullPath, (StringLen($FullPath) - StringInStr($FullPath, "\", 0, -1)))
        $PartNumber = StringTrimRight(StringTrimLeft($FullPath, StringLen($Path)), 4)
    EndIf
EndFunc
Link to comment
Share on other sites

It seems to only take that memory when you open it the first time. I'm checking my total available memory here (not just that of the script), and I get these outputs with the script below:

There is 2017508 memory available
There is 1902436 memory available
There is 1894228 memory available
There is 1893204 memory available
There is 1889108 memory available
There is 1880916 memory available
There is 1880916 memory available
There is 1874772 memory available
There is 1870676 memory available
There is 1862484 memory available
There is 1858388 memory available
There is 1854292 memory available
There is 1850196 memory available
There is 1846100 memory available
There is 1842004 memory available
There is 1837908 memory available

I'm using this script to test:

_Available()

While 1
    $a = FileOpenDialog("Open anything", @DesktopDir, "All (*.*)")
    If @error Then ExitLoop
    _Available()
WEnd

Func _Available()
    $available = MemGetStats()
    $available = $available[6]
    ConsoleWrite("There is " & $available & " memory available" & @CRLF)
EndFunc

I can reproduce this several times. It is not unreasonable of the script to take memory when it is displaying a GUI for the first time? That GUI has to come from somewhere.

Edited by Manadar
Link to comment
Share on other sites

There is 2017508 memory available
There is 1902436 memory available
There is 1894228 memory available
There is 1893204 memory available
There is 1889108 memory available
There is 1880916 memory available
There is 1880916 memory available
There is 1874772 memory available
There is 1870676 memory available
There is 1862484 memory available
There is 1858388 memory available
There is 1854292 memory available
There is 1850196 memory available
There is 1846100 memory available
There is 1842004 memory available
There is 1837908 memory available

Your script is loosing memory as well each time:

There is 2017508 memory available

There is 1902436 memory available -> 115072

There is 1894228 memory available -> 8208

There is 1893204 memory available -> so on...

Slightly modified your test tool to write difference between FileOpenDialog:

Total Memory loss: 744800 x20 FileOpenDialog

Memory loss difference: 559194 x16 (Mine) 179600 x16 (Yours)

There is 8589840376 memory available -> 0
There is 8589676484 memory available -> 163892
There is 8589650744 memory available -> 25740
There is 8589611320 memory available -> 39424
There is 8589583552 memory available -> 27768
There is 8589554116 memory available -> 29436
There is 8589522512 memory available -> 31604
There is 8589491612 memory available -> 30900
There is 8589463140 memory available -> 28472
There is 8589431536 memory available -> 31604
There is 8589396796 memory available -> 34740
There is 8589369028 memory available -> 27768
There is 8589337424 memory available -> 31604
There is 8589309656 memory available -> 27768
There is 8589281184 memory available -> 28472
There is 8589245224 memory available -> 35960
There is 8589214320 memory available -> 30904
There is 8589185848 memory available -> 28472
There is 8589154948 memory available -> 30900
There is 8589124048 memory available -> 30900
There is 8589095576 memory available -> 28472
Link to comment
Share on other sites

I doubt if much can be done about it. FileOpenDialog() just calls a standard Windows dialog so the problem is most likely in the Windows API

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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