[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Garbage Collector collecting the code as it executes?
- From: Matthew Wild <mwild1@...>
- Date: Fri, 2 Dec 2011 06:30:23 +0000
Hi,
On 1 December 2011 01:00, Greg Underwood
<gunderwood@fiercewombatgames.com> wrote:
> Forgive me if this has been discussed already, but I can’t find it after
> spending some time searching the archives. If it has and you have a link,
> please just send me there! :D
>
Obviously your problem is rather technical and your explanation long
and naturally hard to follow which is probably why no-one has
responded yet. But I'm going to make a start:
method_name = lua_tostring(lua_state, 2);
If you say that this is returning garbage because the string that
should be at index 2 has been collected by the garbage collector, this
is (hopefully) incorrect. Either there is a Lua value of type string
(or number) at index 2, in which case Lua will give you a pointer to
that string, or there is not, when Lua will return NULL. It never
returns a pointer to garbage.
One way to end up with garbage would be to store the pointer in C
after the string has been removed from the stack (then the garbage
collector may indeed remove it).
Good luck,
Matthew