Problems with large integer arrays

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with large integer arrays

Cary O'Brien
With Lua 4.0, I can create an array with, say, 20,000 nunbers just
fine.  If I increase to 30,000 numbers the program takes a long time
and also increases memory size to 15 MB or so.

Wierd eh?

-- cary

Lua 4.0 Linux/Red Hat 6.2/pentium

Reply | Threaded
Open this post in threaded view
|

Re: Problems with large integer arrays

Luiz Henrique de Figueiredo
>With Lua 4.0, I can create an array with, say, 20,000 nunbers just
>fine.  If I increase to 30,000 numbers the program takes a long time
>and also increases memory size to 15 MB or so.
>
>Wierd eh?

Yes. It does not happen in my machine (Linux with 128Mb RAM):

% cat i
n = n or 20000
local a={}
for i=1,n do a[i]=i end
execute"ps ufx"

% lua -v n=90000 i
Lua 4.0  Copyright (C) 1994-2000 TeCGraf, PUC-Rio
USER       PID %CPU %MEM  SIZE   RSS TTY STAT START   TIME COMMAND
lhf       4642  0.0  0.8  1572  1068  p1 S    13:56   0:00 -csh 
lhf       4722  0.0  3.1  4508  4056  p1 S    14:00   0:00  \_ lua -v n 90000 i
lhf       4723  0.0  0.4   928   592  p1 R    14:00   0:00      \_ ps ufx 

With 90,000 numbers, it's still only 4.5 Mb.
--lhf