[squeak-dev] About a object life

Bert Freudenberg bert at freudenbergs.de
Mon Nov 5 12:28:25 UTC 2012


On 2012-11-03, at 22:45, Mariano Martinez Peck <marianopeck at gmail.com> wrote:

> On Sat, Nov 3, 2012 at 3:26 PM, Edgar J. De Cleene <edgardec2005 at gmail.com> wrote:
>> Folks:
>> 
>> I wish know how old a object is.
>> 
> The VM can know if an object is in the young or old area. You could modify the VM and make a primitive that answers this (#isYoung: anOop).

What's wrong with the existing primitiveIsYoung? ;)

SmalltalkImage current isYoung: true
==> false

SmalltalkImage current isYoung: Object new
==> true


Also, since our GC does not change the order of objects when compacting, you can tell if an object is older than another by enumerating all objects. The oldest ones are of course nil, false, and true (more than 30 years old now):

(1 to: 20) inject: self someObject into: [:obj :i |
	Transcript show: i; space; show: (obj printString contractTo: 60); cr.
	obj nextObject]
==>
1 nil
2 false
3 true
4 #Processor->a ProcessorScheduler
5 #(#+ 1 #- 1 #< 1 #> 1 #<= 1 #... 1 #new 0 #new: 1 #x 0 #y 0)
6 {Character value: 0 . Charact...$ú . $û . $ü . $ý . $þ . $ÿ}
7 {CompiledMethod . nil . Array...nil . nil . nil . nil . nil}
8 #Transcript->a TranscriptStream ' '
9 #SourceFiles->an ExpandedSour...s/Work/Frank/frank.changes')
10 #Display->DisplayScreen(1920x1200x32)
11 #Sensor->an EventSensor
12 $'
13 $,
14 $-
15 $.
16 $0
17 $;
18 $=
19 $[
20 $_


- Bert -




More information about the Squeak-dev mailing list