lua-users home
lua-l archive

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


On Wed, Jun 10, 2009 at 2:55 PM, Niklas Frykholm<niklas@frykholm.se> wrote:
> 2009/6/10 Olivier Hamel <evilpineapple@cox.net>:
> Currently, if you want to create Complex or Vector3 type you have to
> do it as a table or a userdata. And if you do a serious ammount of
> processing on them, the ammount of garbage generated by simple
> arithmetic operations will soon put a significant strain on the
> system. (You could use a pool of such objects, but that would mean
> resorting to manual memory management with all its pains - especially
> when you are using it for something as simple as numbers.)

Perhaps I am misunderstanding, but if the pool is a table that has
been set to have weak values (i.e. its metatable's __mode field is set
to 'v'), you should not have to do any manual memory management -
values that only exist in the pool will be eligible for garbage
collection.

-Duncan