On 08.05.2009 18:24, Joel VanderWerf wrote: > Robert Klemme wrote: >> Btw, you can easily construct a memory leak, which cannot necessarily >> be detected by counting objects: >> >> ruby19 -e 's="."*1024;t="";loop do t << s end' >> >> I.e., you can grow any String which is not frozen to arbitrary lengths. > > That not really a leak, though, since t is referenced... Well, AFAIK the definition of "memory leak" in GC languages is that of objects kept longer than needed. So if someone creates a program which simply appends text to a String over and over again where creating new short strings would be sufficient he has created a memory leak IMHO. My main point though was to demonstrate that memory usage and object count do not necessarily correlate. > Not that this situation isn't a potential problem, but we should make > sure everyone understands that the blame for it rests squarely on the > programmer and not on ruby's GC. Yep! Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/