From: Brad Phelan Date: 2006-12-20T17:40:08+09:00 Subject: Re: Discovering the number of return arguments requested. > > Actually it is not immediately GC'ed. And when Ruby runs on a JVM then > short lived objects are definitively nothing to worry about. Read here > for example: > http://www-128.ibm.com/developerworks/library/j-jtp01274.html?ca=dnt-54 > Nice article. I remember reading stuff about Java and memory management back in my Java programming days. The copying generation collector would work well with Ruby but does escape analysis work? The Java example given in the article is void doSomething() { Point p = someObject.getPosition(); System.out.println("Object is at (" + p.x, + ", " + p.y + ")"); } ... Point getPosition() { return new Point(myX, myY); } and the Ruby version would be def do_something p = some_object.get_position puts "Object is at #{p.x}, #{p.y}" end The article makes the point that the optimizer can surmise that p is thrown away because it is used only to get it's attributes. However in Ruby p.x and p.y are not public attributes but messages which could result in absolutely anything happening with the reference to the object in p. One day I keep promising myself to peek inside the Ruby interpreter and figure out how it all works. I am sure that is where all the fun is at if I only had the time. Cheers B