| 557 | } |
| 558 | |
| 559 | void LuaEngine::collectGarbage(Maybe<unsigned> steps) { |
| 560 | for (auto handleIndex : take(m_handleFree)) { |
| 561 | lua_pushnil(m_handleThread); |
| 562 | lua_replace(m_handleThread, handleIndex); |
| 563 | } |
| 564 | |
| 565 | if (steps) |
| 566 | lua_gc(m_state, LUA_GCSTEP, *steps); |
| 567 | else |
| 568 | lua_gc(m_state, LUA_GCCOLLECT, 0); |
| 569 | } |
| 570 | |
| 571 | void LuaEngine::setAutoGarbageCollection(bool autoGarbageColleciton) { |
| 572 | lua_gc(m_state, LUA_GCSTOP, autoGarbageColleciton ? 1 : 0); |