[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: out of memory
- From: Julien Cugniere <jcugniere@...>
- Date: Sat, 05 Oct 2002 00:09:29 +0200
Roberto Ierusalimschy wrote:
for i=1,100000 do
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)
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
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.