lua-users home
lua-l archive

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


"John Belmonte" <jvb@prairienet.org> wrote in message
3F012DFF.20903@prairienet.org">news:3F012DFF.20903@prairienet.org...
> Dylan wrote:
> > frog = 10 + 20 + 30 + 40 + 50 + 60
> >
> > Are 6 "value" objects created here and not deleted until the garbage
> > collector runs?
>
> No
>
> > frog = Vector{ 10, 20, 30 } + Vector{ 20, 30, 40 } + Vector{ 30, 40,
50 }
> >
> > Are 3 Vector userdata (or table) objects created and not deleted until
the
> > garbage collector runs?
>
> Yes-- both userdata and table garbage is being generated there.
>
> Your fear is valid.  An incremental GC is the #1 thing Lua needs.  It's
being
> worked on.

This is probably the best angle to work from when arguing my case for a way
of expanding atomic types into tuples.

This makes any arithmetic style of operation on anything other than the
atomic types, really *really* expensive. :-(  There's not much point in
having metatables where you can override operators if this kind of overhead
is lurking in the background.


Right now, If I have 400 aliens each doing pos = pos + vec1 + vec2 + vec3, I
get a leak of 400x3x16=20K each frame.. at 60fps that's 115k a second...6.9
meg a minute...4 gigabytes an hour... and that's without any lua table
structures or malloc overheads in my calculation.

:-(

An incremental garbage collector that will run in any loose time at the end
of the frame would definitely go some way towards improving the situation.
:-)

---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com