lua-users home
lua-l archive

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


Hi,

I'm developing a C++ program which uses lua as scripting language. I need lua to interact with C++ classes, so i'm using full user data of the size of a pointer to store the address of the object. Now sometimes i have to pass objects created in my c code to lua functions; as far as i have understood, the gc will from this moment keep track of these objects and try to free them when they aren't in use anymore by lua. But they are still in use by my program, which will free them on his own when it's the time.

I've often read that I should simply put a copy of my objects somewhere in the registry, so that lua thinks that they're sill in use. But this looks fairly inefficient to me, as i will have to keep in memory a lot of useless data (i know that every object is of the size of a pointer, but on the long run this will consume a lot of memory anyway).

Therefore the key question is: can i tell the gc to fully ignore an object (ie never try to delete it)?


--A. Arri