shornw Posted November 25, 2011 Share Posted November 25, 2011 What are best practises when finished with large arrays? I have a script which compares devices on two domains to identify similar objects. One of the arrays contains >20K lines. Should I be clearing the array before closing the script ie. does it retain the info in the array in RAM when the script closes or is it purged? Apologies if this seems like a silly question. [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 25, 2011 Moderators Share Posted November 25, 2011 shornw, Not silly at all. Just redeclare the array as a simple variable to free the memory: ; Declare a big array Global $aArray[999999][99999] ; Use it [...] ; Empty it and free the memory $aArray = 0 You will obviously need to redeclare it with new dimensions if you need it to become an array again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
shornw Posted November 25, 2011 Author Share Posted November 25, 2011 Thanks Melba [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 25, 2011 Share Posted November 25, 2011 does it retain the info in the array in RAM when the script closesCertainly not. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
UEZ Posted November 25, 2011 Share Posted November 25, 2011 The question is what is happening with the occupied memory by the array when the script exits? Will the memory be freed up automatically or is it better to reset the array to zero? Maybe a dev can answer. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 25, 2011 Moderators Share Posted November 25, 2011 UEZ,Surely all memory used by a script is released when the script ends? As an array is just a list of variables, I see no reason why the memory used should not be released. Certainly in prolonged testing periods with scripts using very large arrays I had no memory troubles. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted November 25, 2011 Share Posted November 25, 2011 (edited) Melba, I'm asking because I don't know how Windows is handling the memory (memory management) in detail. Maybe it is better to release the memory from the script to avoid any memory defragmentation or similar effects... Br, UEZ Edited November 25, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Shaggi Posted November 25, 2011 Share Posted November 25, 2011 Melba,I'm asking because I don't know how Windows is handling the memory (memory management) in detail.Maybe it is better to release the memory from the script to avoid any memory defragmentation or similar effects...Br,UEZOn process closure, windows deletes all memory associated with the process (2-4 GB for 32 bit), together with dll's, resources and such. You cannot cause a memory leak globally after a process closure, since all memoryspace for processes are independently managed and thus can be released safely on closure.You can however cause handle leaks. Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG 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