Accessing Object Memory

Peter Crowther peter.crowther at networkinference.com
Mon Nov 12 20:14:03 UTC 2001


> From: Jack Newton [mailto:newton at ualberta.ca]
I'm interested in storing a reference to a Smalltalk object in a 32 bit word
array.  A seemingly convenient way to do this would be to store the object
pointer for the object into the array, then later retrieve the object given
its object pointer by accessing Squeak's object memory.

Never try to get a direct memory reference to a Squeak object as the GC will
move it.  And you can't get more than a 12-bit OOP either, so they aren'y
unique.

However, all is not lost.  Make the word array a Smalltalk object (an Array
would do fine), register it as a special object, and use the calls to get
element N of the array to find your object wherever it happens to be.

		- Peter




More information about the Squeak-dev mailing list