Recoveryelf Posted August 4, 2012 Share Posted August 4, 2012 Anytime I use FileOpenDialog or FileSaveDialog there is a 6k jump in memory that does not get cleared upon dialog close.Here is a screenie of my project.Here is example code with sections removed.expandcollapse popup; Includes #include #include ; Initialize Global Variables Global $Error = 1 Global $FileMenuNew Global $FileMenuCtrl Global $FileMenuExit Global $FileMenuLineBreak Global $FileMenuOpen Global $FileMenuOptions Global $FileMenuSave Global $FileMenuSaveAs Global $MainWindowInput Global $MainWindowHandle Global $MainWindowOpenButton Global $NewAttempt Global $OpenAttempt Global $Terminate = 1 Global $WindowHeight = @DesktopHeight * 0.5 Global $WindowTitle = "Iron Manager" Global $WindowWidth = @DesktopWidth * 0.5 Global $WorkingFileHandle Global $WorkingFileName ; Initialize Main GUI CreateMainWindow() ; Main Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $FileMenuExit $Terminate = 0 ExitLoop Case $FileMenuNew $NewAttempt = FileSaveDialog("New Database...", @WorkingDir & "\", _ "Database File (*.dbx)", (2 + 16), "New Database", $MainWindowHandle) Case $FileMenuOpen, $MainWindowOpenButton $OpenAttempt = FileOpenDialog("Open Database...", @WorkingDir & "\" , _ "Database File (*.dbx)", (1 + 2 + 8), "", $MainWindowHandle) EndSwitch If $Terminate = 0 Then ExitLoop WEnd ; Clean Up GUIDelete($MainWindowHandle) Exit Func CreateMainWindow() $MainWindowHandle = GUICreate($WindowTitle, $WindowWidth, _ $WindowHeight, (@DesktopWidth * 0.25), (@DesktopHeight * 0.25)) $FileMenuCtrl = GUICtrlCreateMenu("File") $FileMenuNew = GUICtrlCreateMenuItem("New", $FileMenuCtrl, 0, 0) $FileMenuOpen = GUICtrlCreateMenuItem("Open...", $FileMenuCtrl, 1, 0) $FileMenuSave = GUICtrlCreateMenuItem("Save", $FileMenuCtrl, 2, 0) $FileMenuSaveAs = GUICtrlCreateMenuItem("Save As...", $FileMenuCtrl, 3, 0) $FileMenuLineBreak = GUICtrlCreateMenuItem("", $FileMenuCtrl, 4, 0) $FileMenuOptions = GUICtrlCreateMenuItem("Settings", $FileMenuCtrl, 5, 0) $FileMenuExit = GUICtrlCreateMenuItem("Exit", $FileMenuCtrl, 6, 0) $MainWindowInput = GUICtrlCreateInput("", ($WindowWidth * 0.02), _ ($WindowHeight * 0.025), ($WindowWidth * 0.85), ($WindowHeight * 0.04)) $MainWindowOpenButton = GUICtrlCreateButton("Open...", _ ($WindowWidth * 0.885), ($WindowHeight * 0.02225), ($WindowWidth * 0.1), ($WindowHeight * 0.045)) GUISetState(@SW_SHOW, $MainWindowHandle) EndFunc ;==>CreateFirstWindowHelp anyone?~Recoveryelf Link to comment Share on other sites More sharing options...
wakillon Posted August 4, 2012 Share Posted August 4, 2012 Search for ReduceMemory Function By curiosity what's Iron Manager ? is there a link with Srware Iron browser ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Recoveryelf Posted August 4, 2012 Author Share Posted August 4, 2012 There is no link. It's a Data Manager I'm writing for a non-profit. Everything except the encryption engine will be open source when it's finished. ~Recoveryelf Link to comment Share on other sites More sharing options...
water Posted August 4, 2012 Share Posted August 4, 2012 6K? How much memory does your machine have? Why bother? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki  Link to comment Share on other sites More sharing options...
BrewManNH Posted August 4, 2012 Share Posted August 4, 2012 What version of AutoIt are you using? There was a bug in versions prior to 3.3.7.0 with FileOpen and the memory consumption of using it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Recoveryelf Posted August 4, 2012 Author Share Posted August 4, 2012 (edited) I've already done tests to find out that it's not FileOpen, but any of the FileOpen/Save dialogs do cause the memory spike. I'm a traditional programmer so I want my applications to be as small as possible and do run memory tests on every feature. The goal is to create a program that runs as fast and efficent as possible. I know I'm asking a lot out of an automated language but 6k on a dialog box could turn into much more in the size of this project. I'm using v3.3.8.1. My machine has 6gb. But 6k is not something to scoff at, IMHO. Edit: Just not enough time to do it with a low-level language and do not want java as a requirement. Must be a standalone exe. ~Recoveryelf Edited August 4, 2012 by Recoveryelf Link to comment Share on other sites More sharing options...
water Posted August 4, 2012 Share Posted August 4, 2012 From the code you posted I didn't get the impression that this is a 7x24 service script. So the 6k wouldn't sum up to a big amount of "lost" storage causing problems. I'm an old mainframe programmer and started with 36k of core memory. We had to carefully use the memory we had. But nowadays I wouldn't invest too much time in searching the reason for this lost memory. Just my 0.02$ My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki  Link to comment Share on other sites More sharing options...
Recoveryelf Posted August 5, 2012 Author Share Posted August 5, 2012 Still... it is a bug. Link to comment Share on other sites More sharing options...
guinness Posted August 5, 2012 Share Posted August 5, 2012 Still... it is a bug.Have you tested just using FileOpenDialog or FileSaveDialog alone? If there is no jump then there is no bug with those functions. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recoveryelf Posted August 6, 2012 Author Share Posted August 6, 2012 Yes, I have. FileOpenDialog and FileSaveDialog both do the same thing. Also, for every use of the dialog it adds 200kb memory which does not free. Link to comment Share on other sites More sharing options...
BrewManNH Posted August 6, 2012 Share Posted August 6, 2012 Are you sure it's an AutoIt problem and not a Windows problem? Have you done any testing using something similar in another language and watching the memory usage? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Xandy Posted August 6, 2012 Share Posted August 6, 2012 (edited) ;I think this function was written by god. Func _ReduceMemory($i_PID = -1);I use this function to greatly reduce the amount of memory Runner absorbs. if $i_PID <> -1 then local $ai_Handle = dllcall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) $ai_return = dllcall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) dllcall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) else $ai_return = dllcall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Endif return $ai_return[0] EndFunc ;==>_ReduceMemoryDoes calling the _reducememory() function after the dialog calls free the memory? If you run it in a loop (which I may test) how far does the leak go? Does it tapper off, leak forever into virtual memory, or what?writing a test Edited August 6, 2012 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
water Posted August 6, 2012 Share Posted August 6, 2012 Anytime I use FileOpenDialog or FileSaveDialog there is a 6k jump in memory that does not get cleared upon dialog close.By 6k do you mean the difference between 2,680 k to 8,516 k from the screenshot posted on your first post? If yes, then it is not 6k but 6 megabyte. When I run the following compiled test script I get 2,168 K at the start and 7,040 K after the FileOpenDialog. msgbox(0, "Test", "Start ...") FileOpenDialog("Titel","","")For me it's Windows using the memory. BTW: I'm running Windows 7 64 bit. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki  Link to comment Share on other sites More sharing options...
JohnOne Posted August 6, 2012 Share Posted August 6, 2012 Certainly does seem like a memory leak. I just looped it 100 times and it went to around15MB of memory, win 7 32. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Xandy Posted August 6, 2012 Share Posted August 6, 2012 Two scripts script 1: makes a dialog in a loop script 2: sends escape to dialog to aquire next dialog in loop choose and compile one, on first test I did not see any memory increase maybe I need to choose a file idk ;////// test dialog to test the dialog #include <misc.au3>;give me _ispressed() #include <GUIConstantsEx.au3>;give me $gui_event_close $hgui= guicreate("I test", 320, 200) guisetstate() do $msg= guigetmsg() $loadname = fileopendialog("Unique fileopendialog test", @scriptdir, "", "", $hgui) until $msg= $gui_event_close Func _ReduceMemory($i_PID = -1); I use this function to greatly reduce the amount of memory Runner absorbs. I think this functin was written by god. if $i_PID <> -1 then local $ai_Handle = dllcall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) $ai_return = dllcall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) dllcall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) else $ai_return = dllcall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) Endif return $ai_return[0] EndFunc ;==>_ReduceMemory #include <misc.au3>;give me _ispressed() #include <GUIConstantsEx.au3>;give me $gui_event_close $hgui= guicreate("I send keys at test", 320, 200) guisetstate() do $msg= guigetmsg() $list = winlist("Unique fileopendialog test") if $list[0][0]> 0 then controlsend($list[1][1], "", 0, "{ESC}") endif;endif list> 0 until $msg= $gui_event_close Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
water Posted August 6, 2012 Share Posted August 6, 2012 When we talk about memory, which of the 7 values the task manager offers do we talk about? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki  Link to comment Share on other sites More sharing options...
JohnOne Posted August 6, 2012 Share Posted August 6, 2012 Private working set AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Xandy Posted August 6, 2012 Share Posted August 6, 2012 I used the Memory Usage fieldhttp://www.youtube.com/watch?v=LXdHrOfeS7g&feature=youtu.be Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Bowmore Posted August 6, 2012 Share Posted August 6, 2012 This would appear to be a windows issue. I just tried opening the file open dialog and then clicking the cancel button and repeating the process about 20 to 30 time manually i.e. not using AutoIt in several different applications and for each of them the memory in use increased every time the file open dialog was activated. Not enough to give me any concern as I can not envisage a situation where I would be using the file open dialog hundreds of times. This was on a Windows 7 pro system with 32 GB RAM. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
rover Posted August 6, 2012 Share Posted August 6, 2012 C++ GetOpenFileName memory usage http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/6e30c3fd-fbe2-4f2d-8f7c-171f31cae04a As pointed out in that forum, the system shell code causes this. I might add that there are GDI/USER object and handle leaks as well. If this is an issue, I suggest launching the FileOpen dialog as a separate process and get the return data using inter-process communication, i.e. WM_COPYDATA, mailslots, etc. I see fascists... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now