This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Re: 18 Million Billion
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Richard Demers points out that there will be 18 million billion addresses to store objects in to with 64-bit Smalltalk and he ponders the implications of using that much memory and having that many objects.
So I thought it would be fun to find out just how big most objects are in a typical VisualWorks system. Exclusing arrays, all 'data' objects that link to other objects range from having 0 instance variables up to 72 instance variables.
Number of instance variables in a class vs number of classes that have that number of instance variables:
0-5 instance variables: 1852
6-10 instance variables: 5069
11-15 instance variables: 710
16-20 instance variables: 182
21-30 instance variables: 97
31-72 instance variables: 23
Now, just because there are more classes with low numbers of instance variables doesn't mean they're more likely to be instantiated in a system - but, in general principle, on a hunch, I'd say that's very likely to happen. So we're looking at between 0-15 instance variables per object. Lets err towards 10 instance variables, 8 bytes per pointer, so we're using 80 bytes of memory for an object.
Now, for something more gutsy in our system. How many strings do we have and how much space do they take up? Same for arrays:
Number of Strings: 111,155
Size of Strings: 3,230,686
Number of Arrays: 97,460
Size of Array (8 bytes per pointer): 746,318 * 8 = 5,970,544
Number of OrderedCollections: 4,874
Size of OrderedCollection (8 bytes per pointer): 21,667 * 8 = 173,336
I've got no conclusions to make from this, I was just curious about the shape and nature of memory usage in a typical Smalltalk application. And there we have it.