我不擅长英语。所以我得到谷歌翻译的帮助。
我使用c ++控制台应用程序和lua开发MMORPG服务器。 (visual studio 2015 update 2)
我注意到使用visual studio 2015 digonose工具导致内存泄漏。 据报道,该工具发生在Lua。
我尝试了各种方法,但我发现了一件奇怪的事情。 如果执行lua_pcall之后分配的内存大小超过大约210KB,则不能恢复所有内存。
检查点在lua_pcall和lua_close执行之后。 在本机c ++控制台应用程序中重复使用visual studio断点移动相同的lua文件。
我不知道为什么会这样。 任何提示都很好,我想给。
===== Executing Lua File In C++ ======
bool lua_util::dobuffer(lua_State *L, const char* buff, size_t len)
{
size_t offset = skipBOM( buff, len );
if( 0 < offset )
{
buff+= offset;
len -= offset;
}
bool result = true;
lua_pushcclosure(L, on_error, 0);
int errfunc = lua_gettop(L);
if(luaL_loadbuffer(L, buff, len, "lua_util::dobuffer()") == 0)
{
lua_pcall(L, 0, 1, errfunc);
}
else
{
print_error(L, "%s", lua_tostring(L, -1));
result = false;
}
lua_remove(L, errfunc);
lua_pop(L, 1);
return result;
}
======= Lua File ========
npc_220000 = deepcopy( npc_template )
npc_220000[state_spawn] =
{
enter = function( npc )
npc:set_key_value( 1911101, 0 )
npc:set_key_value( 1911102, 0 )
npc:set_key_value( 1911103, 0 )
npc:set_key_value( 1911104, 0 )
npc:set_key_value( servantSpawnId, 0 )
npc:set_timer( 1911102 )
-- 불바다 사용 이후 물표식 제거를 위한 key_value
npc:set_timer( 1911001 )
npc:set_key_value( 1911001, 0 )
end,
decide = function( npc )
end,
exit = function( npc )
end
}