Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualO-san

Posted 09 May 2012 - 02:52 AM

Hello,
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.

#1O-san

Posted 09 May 2012 - 02:51 AM

Hello,
I'm trying to clean the lua stack by using the following piece of code:
int i=0, prev=1;
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.

PARTNERS