Posted 21 September 2012 - 10:14 PM
So, I decided to see how many functions would fit on the stack, and I'm sort of perplexed by the result.
So, maybe the stack size is 256?
But then, if I run it again without rebooting the computer, the vm error does not occur. It prints numbers up to 243 then writes "178", which cursory searches on this forum seem to suggest is an exit code.
Each subsequent run of this program prints one fewer lines.
My question is: Is this normal, or is this triggering some kind of memory leak? Am I not really overflowing the stack? Is the stack supposed to be cleared after the program terminates?
-- Blow your stack for educational purposes.
local _I = 1
local function stack_test()
print("Your stack held " .. _I .. " functions.")
_I = _I + 1
stack_test()
end
The first time it is run, it prints up to 244 and then I get a vm error from bios line 40
java.lang.ArrayIndexOutOfBoundsException: 256.
So, maybe the stack size is 256?
But then, if I run it again without rebooting the computer, the vm error does not occur. It prints numbers up to 243 then writes "178", which cursory searches on this forum seem to suggest is an exit code.
Each subsequent run of this program prints one fewer lines.
My question is: Is this normal, or is this triggering some kind of memory leak? Am I not really overflowing the stack? Is the stack supposed to be cleared after the program terminates?