lua-users home
lua-l archive

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


Hi,

jason zhang wrote:
> I build a Lua5.1 interpreter in Linux, without any library. From the /proc/pid/status,
> It show that the Lua interpreter use about 1M RSS memory. Is this the minimum memory usage of Lua?

No. You are counting libc, libm, libdl, /lib/ld overhead, too.
And most of this is shared with other processes. Even the Lua
part is mostly shared code/data. You can get the heap allocation
with collectgarbage("count") (in Kilobytes).

You want to have a look at:

  # Shows the static code/data size:
  size `which lua`

  # The first few lines are due to Lua, the rest is libc et al.
  # The libc heap is usually overallocated and only a few K are committed.
  lua -e 'os.execute("cat /proc/$PPID/maps")'

Summary:

* read-only (shared) code/data: 40K-200K, depending on compiler
  options (-Os vs. -O3) and whether the parser is included.
  This is for x86 code; somewhat more for most other (RISC) CPUs.

* read-write heap: 18K with standard libs, as low as 1K without.

Bye,
     Mike