Hi Moose users,
as you may know, at Synectique we experiment lots of issues about memory usage.
That's why i had a look at the number of unused instance variables in one of our system loaded with a big model from one of our main customer.
Total instance variables: 26.852.653
Used instance variables: 17.393.938
Empty collections: 5.023.508
Recoverable instance variables: 14.482.223
The recoverable instance variables are those with nil or an empty collection (or MultiValueLink)
As you can see, we can save a lot of memory :-)
Here is my (dirty) code to get that:
countUsedInstanceVariableInForSubInstances: aClass
| usedInstNbr instNbr emptyCollNbr |
usedInstNbr := 0.
instNbr := 0.
emptyCollNbr := 0.
aClass
allSubInstancesDo: [ :anEntity |
instNbr := instNbr + anEntity class allInstVarNames size.
anEntity class allInstVarNames
doWithIndex: [ :e :i |
(anEntity instVarAt: i)
ifNotNil: [ :content |
([
content isEmpty.
emptyCollNbr := emptyCollNbr + 1.
false ]
on: MessageNotUnderstood
do: [ false ])
ifFalse: [ usedInstNbr := usedInstNbr + 1 ] ] ] ].
^ {('Used instance variables' -> usedInstNbr).
('empty collections' -> emptyCollNbr).
('Recoverable instance variables' -> (instNbr - (usedInstNbr - emptyCollNbr))).
('Total instance variables' -> instNbr)}
--
Guillaume Larcheveque