Smalltalk and Object Orientation: an Introduction - Free
Smalltalk and Object Orientation: an Introduction - Free
Smalltalk and Object Orientation: an Introduction - Free
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
30.3.3 PermSpace<br />
This is used to house objects which are rarely eligible for garbage collection. Examples of such objects<br />
are the system classes, tools <strong><strong>an</strong>d</strong> compilers. None of the garbage collections attempt to process this area<br />
of memory except the “Global garbage collector”. This is initiated by the user from the VisualLauncher.<br />
Again this is a perform<strong>an</strong>ce “tweak” <strong><strong>an</strong>d</strong> me<strong>an</strong>s that most of the time items such as a class do not have<br />
to be checked to see if the memory they occupy should be reclaimed nor must PermSpace be<br />
compacted.<br />
30.4 Garbage collection <strong><strong>an</strong>d</strong> memory compaction<br />
There are a number of different ways in which garbage collection <strong><strong>an</strong>d</strong> memory compaction c<strong>an</strong> occur.<br />
The first is the “Generation Scavenger”. This is called whenever NewSpace exceeds the scavenge<br />
threshold. It only processes objects in NewSpace (although it does place objects in OldSpace).<br />
Another garbage collector is the incremental garbage collector (or IGC). This is called from<br />
<strong>Smalltalk</strong> code (as opposed to the scavenger which is called automatically by the Virtual Machine). The<br />
IGC reclaims objects in OldSpace, NewSpace <strong><strong>an</strong>d</strong> LargeSpace. It is called the incremental garbage<br />
collector because it works in <strong>an</strong> incremental m<strong>an</strong>ner to avoid disturbing the executing VisualWorks<br />
environment.<br />
The two remaining garbage collectors are the “Compacting Garbage Collector” <strong><strong>an</strong>d</strong> the “Global<br />
Garbage Collector”. These two garbage collect ors are under user control <strong><strong>an</strong>d</strong> are initiated from the<br />
VisualLauncher. The compacting garbage collector is run when the user selects the “Garbage<br />
Collection” option on the special menu on the Launcher. The global garbage collector is run when the<br />
user select the “Global Garbage Collection” option on the same menu (<strong><strong>an</strong>d</strong> processes all of the memory<br />
available).<br />
Finally, there is a data compactor which runs on the OldSpace which does not do <strong>an</strong>y garbage<br />
collection, only memory compaction. This runs considerably faster th<strong>an</strong> the garbage collectors.<br />
30.5 Placing objects in PermSpace<br />
PermSpace is <strong>an</strong> error of memory which is intended to hold objects which will never die or which will<br />
only rarely die. This me<strong>an</strong>s that most of the garbage collection methods do not need to worry about<br />
what is in PermSpace, thus reducing the amount of memory they must sc<strong>an</strong>. Obviously some of the<br />
objects in PermSpace may die off, the global garbage collector therefore sc<strong>an</strong>s PermSpace as well.<br />
It is possible to move objects from OldSpace to PermSpac e to increase the perform<strong>an</strong>ce of the<br />
garbage collector. This effect is achieved because by moving objects out of OldSpace the number of<br />
objects which must be considered is reduced. This c<strong>an</strong> have a major effect on the perform<strong>an</strong>ce of the<br />
garbage collector.<br />
When you start up your “cle<strong>an</strong>” image, most of the objects (including classes) present in the system<br />
will be located in PermSpace. When you create new objects these will reside in NewSpace or OldSpace.<br />
To relocate them into PermSpace it is necessary to save the current image using the “Perm Save As ...”<br />
option from the “ File” menu option in the VisualLauncher. This writes the objects in OldSpace into<br />
PermSpace in the saved image. It does not affect where objects are located in the current (executing)<br />
image, only in the saved image. It is therefore necessary to exit the image <strong><strong>an</strong>d</strong> start up the newly saved<br />
image to have <strong>an</strong> executing image, in which the objects are stored in PermSpace.<br />
There will however be a number of objects in PermSpace which are tr<strong>an</strong>sient (i.e . likely to die in the<br />
short term). These objects will have been placed into PermSpace, because all objects, whether or not<br />
you w<strong>an</strong>ted them to, will have been saved into PermSpace. Example of such objects may included<br />
windows, objects with which you were w orking etc. To remove these from the image (thus improving<br />
the perform<strong>an</strong>ce of the garbage collector) perform a global garbage collection. Once you have done this<br />
save the image in the normal m<strong>an</strong>ner (i.e. “ Save as...”). Having started up the newly saved ima ge you<br />
could increase the time taken to start the image by performing one last save of the image. This is<br />
necessary because the global garbage collector compacts the objects in PermSpace. This me<strong>an</strong>s that<br />
when the image is started up, the system must reloca te these objects. If you make one more image, then<br />
the objects will already have been relocated <strong><strong>an</strong>d</strong> the startup time will be minimized.<br />
259