lua-users home
lua-l archive

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


Niklas Frykholm wrote:
I have examined the issue some more and it is not only the mirroring of the world that is the problem, it is also that a lot of objects get created. Every frame about 300 objects are created which means 36000 objects in 2 seconds (at 60 Hz).

Most of these objects come from arithmetic operations on vectors (which are represented as userdata objects), so my best idea right now is to change that to a table representation, which would mean fewer userdata objects (possibly at the cost of performance).

A solution may be to setup an object-recycling/pooling system so that you can 'release' a vector and re-use it later. This would involve manual object management, but could be a performance savior. An enhancement to that system would be to remove items from the pool after some inactivity (ex: during a certain part of time 1000 are used, but later only 500 are being used.. you could probably release some over time, but not all, so that getting new ones isn't horribly slow).