[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tracking memory leaks?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 16 Mar 2005 21:18:50 -0300
> How does one track memory leaks in a Lua application?
In 5.1 it's pretty easy to decide whether the leak is in Lua or in the
application: just define your own memry allocator and add/subtract the
amount of memory accordingly. At exit, print this total, which should be
zero if there is no leak in Lua.
See lauxlib for a memory allocator based on malloc. It should be simple to
add the instrumentation described above. So copy it and modify and call
lua_newstate with it.
For Mac OS X there are probably debugging memory allocators that you can
link to your program insted of malloc and these will probably give much
better information than the simple total.
--lhf