lua-users home
lua-l archive

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


On Jan 08, 2003 at 02:42 +0100, Zdenek Stangl wrote:
> Hello,
> 
> Im new to this list. I've read few posts on memory leaking and garbage
> collecting. Now I have just one question: Is it possible to get growing
> memory usage in application that calls frequently lua script functions,
> pushing new tables with strings and cfunctions ? Freqently = up to 50-times
> per second.

Yes, absolutely, if you generate new data that remains accessible.
For example:

----

history = {}

function handle_request(req)
  -- req is a request to be served

  -- save req in the history buffer
  tinsert(history, req)

  do_the_actual_work(req)
end

----

If do_command() gets called repeatedly, the history table will keep
growing and consuming memory, which can't be collected, because it's
still reachable.  If instead you periodically do "history = {}" to
make the old data unreachable, or you don't use the history table at
all, and don't otherwise keep links to old data, the garbage collector
should be reclaiming that memory.

The symptoms you describe sound a lot like you're somehow keeping
links to generated data.

-- 
Thatcher Ulrich
http://tulrich.com