From: Ben Edwards Date: 2007-05-31T20:49:03+09:00 Subject: Does this code spawn lots of objects? I have the following code:- dbh = DBI.connect('*', '*', '*') smtp = Net::SMTP.start('*') sql = open( "gw.sql", "r" ).read sth = dbh.execute( sql ) sth.fetch_hash do |row| mail = MailFactory.new() mail.to = "ben.edwards@ingenta.com" mail.from = "ben.edwards@ingenta.com" mail.subject = "file from ingenta" mail.text = "Here is the file" mail.attach( "./" + row["IDENTITYID"] + "_" + month + year + ".csv" ); smtp.send_message( mail.to_s(), mail.from, mail.to ) end sth.finish smtp.finish dbh.disconnect This code seems to cause a new object to be created for every iteration of the iterator. However is it true that 'mail = MailFactory.new()' causes the previous Mailfactory object not to have a reference to it and therefore it can be garbage collected? Is there a better way of coding the above? Ben -- Ben Edwards - Bristol, UK If you have a problem emailing me use http://www.gurtlush.org.uk/profiles.php?uid=4 (email address this email is sent from may be defunct)