Microsoft Visual Studio 2008给出了以下警告:
警告C4150:删除指向不完整类型'GLCM :: Component'的指针; 没有破坏者叫
这可能是因为我已经定义了Handles来在几个地方转发声明的类型,所以现在Handle类声称它不会在给定对象上调用析构函数.
我有VLD运行,我没有看到任何泄漏.这实际上不是为此对象调用析构函数,还是"可能不会调用析构函数对象"警告?
还有另外一个内存泄漏问题,哈哈.
当我有两个具有相同功能名称和参数的脚本在不同的线程中运行时,支持不同的环境,第二个线程最终覆盖第一个线程的定义,第一个线程的状态被垃圾收集!
// My thread instancing function
lua_State* LuaInstance::RunInstance(const std::string& fileName)
{
lua_State* L = lua_newthread(m_state);
// Give new thread it's own global table
lua_newtable(L);
lua_newtable(L);
lua_pushliteral(L, "__index");
lua_pushvalue(L, LUA_GLOBALSINDEX); // Original globals
lua_settable(L, -3);
lua_setmetatable(L, -2);
lua_replace(L, LUA_GLOBALSINDEX); // Replace LB's globals
// Run script off new thread
luaL_dofile(L, fileName.c_str());
return L;
}
Run Code Online (Sandbox Code Playgroud)
我基本上试图得到它,以便我可以调用这样的多个脚本(对于游戏引擎):
-- Script 1
function Init(self)
-- Do some stuff
end
-- Script 2
function Init(self)
-- Do some other stuff
end
Run Code Online (Sandbox Code Playgroud)