lua-users home
lua-l archive

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

On Wed, Sep 19, 2001 at 01:23:13AM -0700, Russell Y. Webb wrote:
> You can do incremental collection by only adding code everytime an object is
> allocated as long as it's marked as "in use".  Then you incrementally scan
> through everything marking things "in use" that you can reach, then
> incrementally free everything else, and then incrementally unmark everything
> and start over.  

A tiny nit to pick, or tip (unrelated to Lua)... Any time you have an
algorithm that involves marking, doing something, then unmarking, you can
get rid of the unmarking step.  Rather than think of marking as "set some
variable to true", think of it as "set some variable to the current scan
number".  Then your test for whether something is marked is "does this
variable have the current scan number" rather than "is this variable
true"... When it's time to run your algorithm again, just increment your
scan number and everything is unmarked and ready to go.  Saves you quite a
bit of time for your unmarking traversal. =)

Bret Mogilefsky * Mgr. SCEA Developer Support *