Question/Compact Classes

Dan Ingalls Dan.Ingalls at disney.com
Sat Apr 15 05:13:32 UTC 2000


"Mark Ferma" <squeak_sk at hotmail.com> asked...
>Do You know what does "Compact Class" mean?
>
>When I was looking at ObjectMemory description, I found this:
>'If a class is in the compact class table, then this is the only header 
>information needed.'
>
>Where I can read more about it? (compact class table).

The quote above appears after about 10 lines of information describing the first header word (better than the average class comment, huh? ;-).  What it means is that "this one 32-bit header is the only header information needed" in that case.

You can see the CC table in action in, eg, fetchClassOfNonInt: or fetchClassOf:, and you would be led to look at these if you browsed 'class var refs...' of CompactClassMask and CompactClasses, two of the class vars in Object Memory.  Just typing 'compact' into the methodFinder will also give you more relevant stuff to look at (including how to make your favorite class be compact (fasten seatbelts ;-)).

Is it a worthwhile optimization?  Everyone is polarized about this.  I think if we had it to do over, we would leave this feature out for simplicity and the freedom from having to explain it.  That said, the work is done, it costs very little (but, yes, a little) time, and it does save a signifcant amount of space.

How much does it save?  In any given image, thw following expression will tell you exactly how much space compact classes is saving you:

(Smalltalk compactClassesArray detectSum:
	[:cl | cl ifNil: [0] ifNotNil: [cl instanceCount]])*4

For my daily work image of 13.9MB, this expression reports a savings of 843432 bytes.  It would be over a megabyte if a couple of other classes were compact.  [If you are interested in such statistics, you will also want to run...
	Smalltalk printSpaceAnalysis: 1000 on: 'STspace.txt'
... or one of the other variants, and then peruse the file produced.

Have fun

	- Dan






More information about the Squeak-dev mailing list