lua-users home
lua-l archive

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


> collection etc. Each marker structure is malloced and freed 
> and kept in a
> pool, but when the number of markers in use shrinks by a 
> binary order of
> magnitude the free pool is shrunk. If you are creating loads 
> of user data
> types and and destroying them a lot then this shrinking and 
> growing will
> occur a lot. The same thing occurs for lua strings. The 
> minimum pool size is
> hard wired to be 10 (dont know why, or why so small). Any way 
> below is an
> example patch to increase the pool size and so stop all the malloc and
> freeing.


As well as optimisations like this, what about introducing a "const"
keyword. Any const references to objects would mean the object would not
need to be garbage collected (and the reference could not be altered).
Cutting down the number of objects to be checked would help I think
(although I'm not very familar with Luas internals).

eg.

const function foo()
  print("You'll never throw me in the garbage!")
end

const foo2 = 1234

foo = 5 -- error
foo2 = 5 -- error

boo = foo -- fine