|
Re: terminate event?: msg#00123lang.smalltalk.squeak.beginners
Am Jan 21, 2007 um 15:21 schrieb Bert Freudenberg: Am Jan 21, 2007 um 14:07 schrieb David Urquhart: Here's an example. Evaluate this in a workspace: x := Object new. x toFinalizeSend: #show: to: Transcript with: 'He''s dead, Jim!\' withCRs Nothing should happen. Then do x := nil which should print "was finalized" immediately. This is because x still holds onto a relatively "new" object, which gets freed very fast. However, once an object gets "old" it takes until the next full garbage collection (GC)! Create your object again, but this time, do this: Smalltalk garbageCollect. x := nil. Nothing will be printed, because the GC reclaims all space, but also marks all surviving objects as "old". So even though after assigning nil to x your object is dead, the finalizer does not know it, yet. Only if you trigger a full GC again, the object's space is reclaimed, and the finalizer is activated. - Bert -
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: terminate event?, Bert Freudenberg |
|---|---|
| Next by Date: | Binaural Beats w/ Squeak, Michael Gorsuch |
| Previous by Thread: | Re: terminate event?, Bert Freudenberg |
| Next by Thread: | Re: terminate event?, David Urquhart |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |