lua-users home
lua-l archive

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


Hello Julien
Just today I had time to read your message and test
myself the question.
I ran life.lua with lua 5 and the interpreter reached a
total data segment of 155 kb, until the script finished at
the 2000th generation ( as is stated in the loop ).
You don´t say over wich platform ( hw/OS ) your test
goes so bad. It´s a very interesting question.
My hardware is a PII 233 64Mb, running QNX 4.25.
If you don´t know, QNX does no ram/disk pagination.
----- Original Message -----
From: "Julien Cugniere" <jcugniere@free.fr>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Friday, October 04, 2002 7:09 PM
Subject: Re: out of memory


>
>
> Roberto Ierusalimschy wrote:
> >>  s=""
> >>  for i=1,100000 do
> >>    s=s.."x"
> >>  end
> >
> >
> > Are you sure this is from "life.lua"? I didn't find it there...
> The code I gave isn't; this is a simplification of life.lua's "draw"
method:
>
>    for y=1,self.h do
>     for x=1,self.w do
>        out=out..(((self[y][x]>0) and ALIVE) or DEAD)
>      end
>      out=out.."\n"
>    end
>
>
> > Anyway, that code can really gives an "out of memory" error. This is not
> > a bug, but a limitation of the way Lua manipulates strings. (Java has
> > similar problems.)
> I knew of this limitation (thanks to the wiki actually).
>
> What makes me believe this is a bug is that with lua 5, life.lua dies
after
> about 120 iterations, while it runs fine with lua 4. Similarly, the bit of
code
> I gave runs fine (even though it takes time) with lua 4, but dies quickly
with
> lua 5. Moreover, I can understand that concatenating strings this way is
costly,
> but the corbage collector should reclaim unused memory... instead of that,
> memory usage grows, and once my 256 Mo of RAM are used the hard drive
starts to
> trash and then the program dies...
>
> Anyway, thanks for the reply and the info you gave.
>
> Julien Cugniere
>