[LUAU] programming question, buffer problem?

Tim Newsham newsham at lava.net
Thu Dec 30 12:19:11 PST 2004


> I have a program that uses quite a bit of buffer space.  There are four
> major chunks of buffer space, three declared something like "short
> mybuffer[32][4M]", and the fourth "int myotherbuffer[4][4M]".  Total
> buffer usage comes in at somewhere under 800MB.

by 4M do you mean 4*1024*1024?

> Now, I've seen this happen when you declare to large a chunk of data in
> a function, where I think basically the stack barfs and you get a
> segmentation fault because the data didn't fit.  But these buffers are
> declared in a header file, and I *thought* that meant they'd be loaded
> to the heap, and not have the same problem.

If you declare local variables (non-static) they are allocated
on the stack.  If you declare global variables they are either
in the BSS or data segment (depending on if they are initialized
to zeros or other values).  There are limitations on the amount
of space available on the stack.  I'm not familiar with limitations
in the bss/data.  However, you can avoid them, if they exist, by
allocating the data at runtime using malloc or a similar function.
In that case the data will be on the heap.

Where in the startup does the crash occur?

> -Charles

Tim N.



More information about the LUAU mailing list