From: Roger Pack Date: 2007-11-13T04:44:28+09:00 Subject: Re: JRuby performance questions answered > I suggest you look at all the research done on reference counting > algorithms > versus sweep ones. Most if not all research shows that reference > counting is slower > and more prone to bugs than modern techniques. Just throwing this thought out for public feedback. I noticed that some other scripting languages use Reference counting. Ok just Python. Here are its reasons (for feedback). ==Begin quote Why doesn’t Python use a more traditional garbage collection scheme? For one thing, this is not a C standard feature and hence it’s not portable. (Yes, we know about the Boehm GC library. It has bits of assembler code for most common platforms, not for all of them, and although it is mostly transparent, it isn’t completely transparent; patches are required to get Python to work with it.) Traditional GC also becomes a problem when Python is embedded into other applications. While in a standalone Python it’s fine to replace the standard malloc() and free() with versions provided by the GC library, an application embedding Python may want to have its own substitute for malloc() and free(), and may not want Python’s. Right now, Python works with anything that implements malloc() and free() properly. Note that on systems using traditional GC, code that uses external resources without explicitly releasing them may run out of resources before the GC kicks in. Consider this example: class Resource: def __init__(self, name): self.handle = allocate_resource(name) def __del__(self): if self.handle: self.close() def close(self): release_resource(self.handle) self.handle = None ... for name in big_list: x = Resource(name) do something with x In current releases of CPython, each new assignment to x inside the loop will release the previously allocated resource. Using GC, this is not guaranteed. ==End Quote Oh except that in current Ruby it is still guaranteed to free (in its own klunky way). Any thoughts? -- Posted via http://www.ruby-forum.com/.