From: Ron Jeffries Date: 2002-03-07T04:36:06+09:00 Subject: object size and overhead. My set program was turned loose yesterday to build a hundred thousand objects. Here's the code: def testLots set = Set.empty (0..99999).each { | i | set.insertUniqueAt(i,makeR1) } end def makeR1 r1 = Set.fromArray r1.insertAt('name', 'jeffries') r1.insertAt('state', 'MI') r1 end The Set.from array has two arrays inside that basically hold the 'name', 'state' items and the 'jeffries' 'MI' items. So the Set created has two instance variables, an array of scopes and one of elements. It looks like this. # Running this thing at 100,000 records uses 60 megs of memory. I see 7 objects per set, so 60,000,000 / 600,000 = 100 bytes per object, which seems a bit rough. So my question is ... what's the overhead in a Ruby object. And my second question is: ask what I /should/ have asked and answer that too. Thanks! Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.