WeakArray.finalizationProcess problem

caniglia at dm.uba.ar caniglia at dm.uba.ar
Sun May 20 14:55:31 UTC 2001


In the finalizationProcess method the last element of
FinalizationDependents gets referenced by the block
variable weakDependent (see below). Since this is an
endless process, this last element is never garbage
collected. 

A simple way to fix the bug is by niling
the variable. Here is the code:

finalizationProcess

	[true] whileTrue:[
		FinalizationSemaphore wait.
		FinalizationLock critical:[
			FinalizationDependents do:[:weakDependent|
				weakDependent isNil 
					ifFalse:[weakDependent finalizeValues.
						weakDependent _ nil "*** FIX ***"].
			].
		] ifError:[:msg :rcvr| rcvr error: msg].
	].

Also note that changing the method does not solve the
problem since the original process is still alive. One needs
to evaluate some expressions taken from the initialize method:

	FinalizationProcess notNil ifTrue:[FinalizationProcess terminate].
	FinalizationProcess := [self finalizationProcess] newProcess.
	FinalizationProcess priority: Processor userInterruptPriority.
	FinalizationProcess resume.

/leandro





More information about the Squeak-dev mailing list