lua-users home
lua-l archive

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


Hi,

We are using LUA in our current game, but we are currently 
experiencing horrible memory leaks with it. We did modify the lua 
code slightly(actually just the lstate.h) file where I added a couple 
of pointers..
<---Code changes to lstate.h--->
{Rest of lua_State struct up here}
  lua_Hook callhook;
  lua_Hook linehook;
  int allowhooks;
  /* Additional Pointer reference for class. Added by Terence */
  void * pMemory;   /* Access to Memory subsystem */
  void * pComms;    /* Access to Communicatin subsystem */
  void * pEvent;    /* Access to Event Sub-System */
  void * pAI;       /* Access to AI Sub-System */
  void * pScene;    /* Access to scene management subsystem */
  void * pLog;      /* Access to central error logger(for debug) */
  void * pProc;     /* ProcMgr */
  unsigned long dwCharID;
  unsigned short wEventID;
  void * pData;
  void * pSendThread;
  void * pTaskMgr;
};
<--------Done----->

I have tried:
1) Calling collectgarbage(0) at all return points in scripts
2) I tried reseting the stack to its original position by calling
lua_gettop(L) and then call lua_dobuffer() and then call lua_settop
3) I tried call lua_setgcthreshold(L,0) after a lua_dobuffer() has 
been run
4) I have even recompiled it using the g++ compiler
5) I have integrate and replaced lmem.c realloc with dalloc(as stated 
in one of the lua wiki's)

And its still leaks..
My questions(some are pretty silly showing how desperate I am)
1. As anybody else had any problems running this.. I am calling a lua 
script pretty often..it's a game after all..
2. would compiling it in debug mode or running gdb with it cause any 
issues
3. Is is possible to re-write lmem.c to put use a static set pool of 
memory instead of a rapid growing one..
4. Do to many calls to lua_newtable( always check that I pop it off 
and try to keep the stack state every time I call my API's) or 
anything contribute to the leak..what should I look at...(more 
specifically which API's or what can cause leaks

Sorry bout the long post.

Terence

PS..when I try to call lua_close..the entire app segmentation 
faults... with the following code 
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 2051 (LWP 28072)]
0x080657ed in lua_pushnumber__FP9lua_Stated (L=0xc00cd10, n=1) at 
lapi.c:209
209       nvalue(L->top) = n;
Current language:  auto; currently c
(gdb) bt
#0  0x080657ed in lua_pushnumber__FP9lua_Stated (L=0xc00cd10, n=1) at 
lapi.c:209
#1 

I am using LUA4.0(I tried 4.1 work4) and it has the same problem.