How to swap out an object using an image segment
Last updated at 7:55 am UTC on 23 March 2003
The following method shows how an object may be "swapped out" into an ImageSegment and thus reducing the footprint ot the main .image file. The object is automatically brought in again if is is used again.
The example shows a method from an "account" object I have:
"Swaps out this object using an ImageSegment.
Returns the ImageSegment created. Each reference to me or into
any of my parts will be turned into an ImageSegmentRootStub
which acts as an autoloading proxy thus bringing me back in
at first access. The stubs know the ImageSegment so it does not need
to be remembered. The ImageSegment can be brought in
directly by calling #install on it."
| is myParent |
myParent _ parent.
parent _ nil.
is _ ImageSegment new.
is copyFromRoots: (Array with: self) sizeHint: 500000 areUnique: true.
is segmentName: 'account', id fullPrintString.
is extract; writeToFile.
parent _ myParent.
This would "swap out" the object and replace all references with autoloading stubs. It works like a charm! And especially loading it back in is FAST.