I'm trying to clean the lua stack by using the following piece of code:
int i=0, prev=1,count=0;
while(i!=prev || count<10){
lua_settop (luaVM, 0);
lua_gc (luaVM, LUA_GCCOLLECT, 0);
prev=i;
i=lua_gc(luaVM, LUA_GCCOUNT, 0);
count++;
}
But it doesn't clean entirely. I still have variables that are not 'nil' when the while loop has finished. The variable 'i' never turn zero but I guess that is expected. I do a minimum of 10 garbage collections just to be on the safe side.Thanks for reading.