lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


My guess is it is actually an endless loop. May be you
can try to turn arr={} to local arr={}.


--- Gergo Szakal <bastyaelvtars@gmail.com> wrote:

> Today I was playing with this code and noticed that
> running this with the lua5.1 commandline under
> windows makes lua.exe do a RAM usage spike and then
> freeze. When I open the file in "a+" mode and write
> the stuff into it one by one it Just Works (tm), so
> it seems obvious that the problem lies behind adding
> the stuff to an array. What might be the problem?
> 
> -------------- code follows --------------
> 
>
tbl={["os"]=1,["math"]=1,["string"]=1,["table"]=1,["debug"]=1,["coroutine"]=1,["_G"]=1}
> arr={}
> 
> local f=io.open("_G.txt","w")
> for W,V in pairs(_G) do
>   if type (V)~="table" then
>     table.insert(arr, W)
>   elseif not tbl[W] then
>     for W1,V1 in pairs(V) do
>       table.insert(arr, W.."."..W1)
>     end
>   end
> end
> f:write(table.concat(arr,"\n"))
> f:close()
> 
> -------------- code end --------------
> 
> TIA for answers.
> 
> 



 
____________________________________________________________________________________
Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367