GyuK Posted December 2, 2014 Share Posted December 2, 2014 (edited) i have an function thats gets looped quite some times in my script, it this function: func _iniReadSection($ininame,$inisec) dim $array[1][3] $j = 1 $inih = fileopen($ininame,0) $inifile = FileReadToArray($inih) if ubound($inifile) < 10 Then return 0 EndIf $inifile[0] = (ubound($inifile) - 1) for $i = 1 to $inifile[0] if $inifile[$i] = "[" & $inisec & "]" Then $start = $i + 1 EndIf Next for $i = $start to $inifile[0] if not StringInStr($inifile[$i],"]") Then redim $array[$j + 1][3] $array[$j][1] = stringmid($inifile[$i],1,(stringinstr($inifile[$i],"=")-1)) $array[$j][2] = stringmid($inifile[$i],(stringinstr($inifile[$i],"=")+1)) $j += 1 Else $array[0][0] = ubound($array) - 1 return $array EndIf Next $array[0][0] = ubound($array) - 1 return $array EndFunc if you try to do something like: while 1 $teste = _IniReadSection("config.ini","GERAL") WEnd the script will start getting so many memory till it gets to 4gb of ram and get a error, "Error allocating memory", there is something wrong with the function?, aren't the variables inside function supposed to be released once it reach the "return" line? Edited December 2, 2014 by GyuK Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted December 2, 2014 Moderators Solution Share Posted December 2, 2014 GyuK,You open a file each time you enter the function [fileopen($ininame,0)] but you never close it - Windows will run out of handles pretty quickly, which is probably the cause of your problem. Also, why are you not using the built-in IniReadSection function? It looks as if the array returned from your function is essentially similar. 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...
GyuK Posted December 2, 2014 Author Share Posted December 2, 2014 GyuK, You open a file each time you enter the function [fileopen($ininame,0)] but you never close it - Windows will run out of handles pretty quickly, which is probably the cause of your problem. Also, why are you not using the built-in IniReadSection function? It looks as if the array returned from your function is essentially similar. M23 yup, that was the problem(im so dumb), fixed it thanks "Only the first 32767 chars are read for legacy reasons." cause of that Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 2, 2014 Moderators Share Posted December 2, 2014 GuyK,Glad I could help. 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...
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