lua-users home
lua-l archive

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


hi all,

Has somebody still use tolua/tolua++? I don't understand how it's new_local worked.

when create a new object, tolua put it into a weak-value table named tolua_ubox, it's key is the raw-pointer of object, and it's value is the userdata of object.

but if you marked this object is "need collected", that is, you call tolua.takeownership on it or create it using new_local, then this object will be added into a table named tolua_gc, but this is not a weak table! it means, the object itself may always marked, and will not be collect.

am i missing something?

another question: the code below:

collectgarbage"collect"
print("memory1 is: ", collectgarbage"count")
for i = 1, 1000 do
Obj:new_local()
end
print("memory2 is: ", collectgarbage"count")
collectgarbage"collect"
print("memory3 is: ", collectgarbage"count")

Obj is a C++ class binding by tolua, it seems that memory2 and memory3 is the same! so I don't have my memory back, how do I make my memory back after collect?