[Rant] Shrinking problems and rampant interdependencies

Andreas Raab Andreas.Raab at gmx.de
Tue Jul 24 19:35:09 UTC 2001


Kevin,

> How do I dump the updates?

Here's my (annotated) shrink script - have a look at it and see what might
benefit yours. Note that this one is written under the assumption that:
a) All windows have been closed
b) All global flaps were DESTROYED (not just hidden)

	"Delete all projects"
	Project allSubInstancesDo:[:p|
		(p == Project current) ifFalse:[Project deletingProject: p].
	].
	"Fix up for some historical problem"
	Smalltalk allObjectsDo:[:o|
		o isMorph ifTrue:[o removeProperty: #undoGrabCommand].
	].
	"Remove stuff from References"
	References keys do:[:k| References removeKey: k].
	"Reset command history"
	CommandHistory resetAllHistory.
	"Clean out Undeclared"
	Undeclared removeUnreferencedKeys.
	"Reset scripting system"
	StandardScriptingSystem initialize.
	"Reset preferences"
	Preferences initialize.
	"Do a nice fat GC"
	Smalltalk garbageCollect.
	"Dependents mean that we're holding onto stuff"
	(Object classPool at: #DependentsFields) size > 1
		ifTrue: [self error:'Still have dependents'].
	"Initialize Browser (e.g., reset recent classes etc)"
	Browser initialize.
	"Check for Undeclared"
	Undeclared isEmpty
		ifFalse: [self error:'Please clean out Undeclared'].
	"Remove graphics we don't want"
	ScriptingSystem deletePrivateGraphics.
	"Remove a few text styles"
	#(Helvetica Palatino Courier) do:
		[:n | TextConstants removeKey: n ifAbsent: []].
	"Dump all player uniclasses"
	Smalltalk at: #Player ifPresent:[:player|
		player allSubclassesDo:[:cls|
			cls isSystemDefined ifFalse:[cls removeFromSystem]]].
	"Dump all Wonderland uniclasses"
	Smalltalk at: #WonderlandActor ifPresent:[:wnldActor|
		wnldActor allSubclassesDo:[:cls|
			cls isSystemDefined ifFalse:[cls removeFromSystem]]].
	"Attempt to get rid of them"
	Smalltalk garbageCollect.
	"Now remove larger parts"
	Smalltalk
		discardFFI;
		discard3D;
		discardSUnit;
		discardSpeech;
		discardVMConstruction.
	"Dump change sets"
	ChangeSorter removeChangeSetsNamedSuchThat:
		[:cs| cs name ~= Smalltalk changes name].
	"Clear current change set"
	Smalltalk changes clear.
	Smalltalk changes name: 'Unnamed1'.
	Smalltalk garbageCollect.
	"Reinitialize DataStream; it may hold on to some zapped entitities"
	DataStream initialize.
	Smalltalk garbageCollect.
	"Remove refs to old ControlManager"
	ScheduledControllers _ nil.
	"Flush obsolete subclasses"
	Behavior flushObsoleteSubclasses.
	Smalltalk garbageCollect.
	Smalltalk obsoleteBehaviors isEmpty
		ifFalse:[self error:'Still have obsolete behaviors'].

At this point, your image should be at about 5.5 MB. The last test is
actually the most important one. If there's any stuff in the image that
shouldn't be in there it almost always shows up as some sort of obsolete
behavior. Tracking those is important.

Cheers,
  - Andreas





More information about the Squeak-dev mailing list