[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using Lua's memory allocator
- From: Patrick Rapin <toupie300@...>
- Date: Tue, 11 Oct 2011 12:54:09 +0200
It seems to be a good start.
What bothers me is the condition to decide what can be collected or not.
If your code just allocates chunks, perform a local work with it and
then free it, alloca function could also work, at a much lower cost...
If, as I imagine, a chunk must be kept until some other other chunk is
used, it becomes more complicated. You will need to keep references in
Lua (for example with a table in the registry, where the keys are
lightuserdata) in the some way as in C++ the destructors are usually
chained. This can not be done be simply changing calloc in your