Sign in to follow this  
Followers 0
shornw

What to do when finished with arrays

8 posts in this topic

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]

Share this post


Link to post
Share on other sites



shornw,

Not silly at all. Just redeclare the array as a simple variable to free the memory: :D

; 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. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks Melba


[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

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

On 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

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  
Followers 0