lua-users home
lua-l archive

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

Yes, exactly.

Authors should make the guarantees, I can not. And this one might not in fact be as I described. Seems changes in "amount of memory in use by Lua" can trigger the gc, and these can occur from within C functions.

Authors: a word of verdict?  :)


p. 32 (lua-5.0.pdf):
"Because Lua has garbage collection, there
is no guarantee that the pointer returned by lua_tostring will be valid after the corresponding value is removed from the stack. If you need the string after the current function returns, then you
should duplicate it or put it into the registry (see

"The first counts the amount of memory in use by Lua; when the count reaches the threshold, Lua runs
its garbage collector."

Javier Guerra kirjoitti 28.2.2006 kello 8.17:

On Tuesday 28 February 2006 1:09 am, Asko Kauppi wrote:
It is safe to use the returned string, simply because the garbage
collector never runs until you return from your C function back to
Lua. Thus, you can: get a string, pop it, use the pointer.

so what you're saying is that the garbage collector is never called by any Lua API function, but only by the VM itself? is that guaranteed to be so in
future implementations?