lua-users home
lua-l archive

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


2^18 is the limit per function, not per file. Of course, if you file
is a single function (i.e. the unnamed top-level chunk), then 2^18
becomes the file limit.

You can transform code like this:

X = {
  a = "b",
  c = "d",
  e = {
    f = "g",
    h = "i",
  },
  j = "k",
}

Into something like this:

X = {
  a = "b",
  c = "d",
  e = (function() return {
    f = "g",
    h = "i",
  } end)(),
  j = "k",
}

Thus moving some constants out of the top-level and into subfunctions.

On Wed, Aug 5, 2009 at 2:36 AM, Norman Ramsey<nr@cs.tufts.edu> wrote:
> I'm accustomed to use Lua to store persistent data structures on disk.
> Unfortunately, in my latest venture, I run out of string space.  I did
> a little investigation in the source, and it appears that only 2^18
> literal constants may appear in any one source file, and this appears
> to be a hard limit built into the bytecode format.
>
> I would like to write large Lua tables out to disk, possibly nested, but
> with no sharing or cycles.  Does anybody have any suggestions how to
> achieve this without running afoul of the dreaded 'constant table overflow'?
>
>
> Norman
>