lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

 I seem to have a problem with memory in lua ...

This piece of code seems suspect -->

bool Lua::RunString(const std::string &Command)
               //Put error handler on stack
	lua_pushliteral(m_pScriptContext, "OnError");
	lua_rawget(m_pScriptContext, LUA_GLOBALSINDEX);
	int errorFunc = lua_gettop(m_pScriptContext);

	int retCode = luaL_loadbuffer(m_pScriptContext,
				Command.c_str(), Command.size(), NULL);

	if (retCode)
		Log(ELOGSEV_CRITICAL, lua_tostring(m_pScriptContext, -1));
		return false;

	int callRetCode =
		lua_pcall(m_pScriptContext, 0, LUA_MULTRET, errorFunc);
	if (callRetCode)
		// Report runtime error message
		if(callRetCode != LUA_ERRRUN)
			Log(ELOGSEV_CRITICAL, lua_tostring(m_pScriptContext, -1));
		return false;
	return true;

a) This just runs a command on the lua state
b) When I run this over and over again, if I look at the totalbytes field in the lua state, it grows slowly. It does not increase for every run but does it every 10 or maybe 20 calls.
c) I am using LUA 5.1 on a fedora core 2 box.

Any help is appreciated ...

                      P Saravanan

Spice up your IM conversations. New, colorful and animated emoticons. Get chatting!