lua-users home
lua-l archive

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

On Thursday 04 February 2010, Philipp Janda wrote:
> Why are you doing that? You don't get deterministic cleanup of Lua
> values anyway, and IIRC, the stack slots are removed when the function
> returns.

But if the C++ function does not return soon? If the C++ function does use a 
lot of (temporary) C++ objects representing Lua variables (e.g. inside 
a C++ loop body) and does call other C++ functions that are also using slots 
on the stack, the stack might get full of unused stack slots.

> It does (sort of): Use lua_pushnil + lua_replace instead of lua_remove.

So you mean to set the unused stack slot to nil value? This does not 
reduce the stack usage.

Maybe the concept of unused stack slots is not useful in every usage 
situations. But it might be useful in cases where one wants to keep
track the stack slot usage through C++ objects.

Best regards,