[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Thinking about Lua memory management
- From: Roberto Ierusalimschy <rieru@...>
- Date: Thu, 20 Sep 2001 09:32:12 -0500 (CDT)
On Thu, 20 Sep 2001, David Jones wrote:
> A generational GC sounds very sensible. I have a few questions, mostly
> out of idle curiosity.
>
> Have you read, Wilson excellent survey paper "Uniprocessor Garbage
> Collection Techniques"? (online at
> ftp://ftp.cs.utexas.edu/pub/garbage/bigsurv.ps
> )
Yes. I also read the book
"Garbage Collection : Algorithms for Automatic Dynamic Memory Management"
by Richard Jones & Rafael Lins (John Wiley & Son, 1996). It is very good.
> Are you planning to move objects?
No... Among other problems, GC can happen while C code keeps pointers to
strings inside Lua. Moreover, Lua does a lot of realloc's, so to compact
memory too tightly for some arrays may not be a good idea.
> How are you going to represent generations?
Just a small number on the object? Lua keeps a list of all objects,
and those lists are naturally ordered by creation time: Young objects
are always in the front.
> I assume you are using a write barrier to implement "remembered sets" -
> pointers from objects in old generations to objects in younger
> generations? How are you planning on representing your remembered sets?
Linked lists. Tables already have an extra pointer, used during GC. (My
remembered sets would not keep the pointers, but the objects [tables] with
such pointers.)
Actually, there are other objects with references: closures and prototipes.
But they are read-only, and so they can never point to a younger object.
Only tables can have pointers to younger objects.
-- Roberto