[Pharo-project] About a object life
Folks: I wish know how old a object is. Any have code for this ? Thanks in advance Edgar
Re: [Pharo-project] About a object life
Only for new objects? If so, you could add an instance variable to Object and store a timestamp. On 03.11.2012, at 15:26, Edgar J. De Cleene wrote: > Folks: > > I wish know how old a object is. > > Any have code for this ? > > Thanks in advance > > Edgar
Re: [Pharo-project] About a object life
On Sun, Nov 4, 2012 at 2:45 PM, Max Leske wrote: > Only for new objects? If so, you could add an instance variable to Object > and store a timestamp. > > Well, kind of ;) Because if you do that, your image will crash. This is because the VM directly accesses (by offset) certain instVars of certain classes. For example, it knows that the MethodDictionary of a class is at the offset 2. So, if you add an instVar to Object all these offsets will be shifted, and VM will be accessing incorrect places, and therefore, a crash :) > > On 03.11.2012, at 15:26, Edgar J. De Cleene > wrote: > > Folks: > > I wish know how old a object is. > > Any have code for this ? > > Thanks in advance > > Edgar > > > -- Mariano http://marianopeck.wordpress.com
Re: [Pharo-project] About a object life
ups :) On 04.11.2012, at 15:04, Mariano Martinez Peck wrote: > > > > On Sun, Nov 4, 2012 at 2:45 PM, Max Leske wrote: > Only for new objects? If so, you could add an instance variable to Object and > store a timestamp. > > > Well, kind of ;) Because if you do that, your image will crash. This is > because the VM directly accesses (by offset) certain instVars of certain > classes. For example, it knows that the MethodDictionary of a class is at the > offset 2. So, if you add an instVar to Object all these offsets will be > shifted, and VM will be accessing incorrect places, and therefore, a crash :) > > > > On 03.11.2012, at 15:26, Edgar J. De Cleene wrote: > >> Folks: >> >> I wish know how old a object is. >> >> Any have code for this ? >> >> Thanks in advance >> >> Edgar > > > > > -- > Mariano > http://marianopeck.wordpress.com >
Re: [Pharo-project] About a object life
Hi Edgar-- Do you really want to know how old an object is, or just whether it's older than some other object? If you don't care about degrading the identity hash distribution, you could steal a few bits from the object header for a counter. -C -- Craig Latta www.netjam.org/resume +31 6 2757 7177 + 1 510 396 5727
Re: [Pharo-project] About a object life
On 11/4/12 4:33 PM, "Craig Latta" wrote: > > Hi Edgar-- > > Do you really want to know how old an object is, or just whether > it's older than some other object? If you don't care about degrading the > identity hash distribution, you could steal a few bits from the object > header for a counter. Craig: Like to know how old an object is. As my reply to Hans-Martin, guess this is not possible in current Pharo/Squeak. Nice to read you ! Edgar