Hello, I have a morph which forks a process. What is the best way to terminate the process when my morph gets garbage collected? I tried to use finalization, but for some reason it doesn't work. Mateusz
If the process has a strong reference to your morph (via self, a local variable, etc), or any other object referencing your morph (e.g. the home context of the block of the process), then the morph won't get garbage collected while the process is running. If it only has a weak reference to the morph, then it can check if the morph got garbage collected (the weak reference became nil), and terminate normally.
Levente
On Wed, 11 Dec 2013, Mateusz Grotek wrote:
Hello, I have a morph which forks a process. What is the best way to terminate the process when my morph gets garbage collected? I tried to use finalization, but for some reason it doesn't work. Mateusz _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Levente Uzonyi pisze:
If the process has a strong reference to your morph (via self, a local variable, etc), or any other object referencing your morph (e.g. the home context of the block of the process), then the morph won't get garbage collected while the process is running. If it only has a weak reference to the morph, then it can check if the morph got garbage collected (the weak reference became nil), and terminate normally.
Levente
Oh, so that's the reason the finalization didn't work. I suppose I need to split the morph into two and keep a weak reference between them. Thanks! Mateusz
beginners@lists.squeakfoundation.org