Hi Ang,<div><br></div><div>    when a snapshot is written the heap is simply written to the file, so all the object addresses in the file are those the objects had in the address space of the process that wrote the snapshot.  The start address of the heap is written to the snapshot file&#39;s header in the oldBaseAddr field.  So nil, which is the first object in the heap, has address oldBaseAddr.  So nil&#39;s address - oldBaseAddr is zero.  i.e. subtracting oldBaseAddr converts an absolute heap address into a releative one where the heap starts at 0.</div>
<div><br></div><div>When a snapshot is loaded, the VM asks the OS to allocate memory for the heap and assigns the start of this memory to memStart.  Therefore to load a snapshot file at the new address, memStart, all pointers in the heap must be adjusted by memStart - oldBaseAddr.</div>
<div><br></div><div>HTH<br><br><div class="gmail_quote">On Mon, Aug 24, 2009 at 11:13 AM, Ang Beepeng <span dir="ltr">&lt;<a href="mailto:beepeng86@yahoo.com">beepeng86@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi all.<br>
<br>
I do not understand the usage of oldBaseAddr. In VM source,<br>
<br>
<br>
oldBaseAddr = getLongFromFileswap(f, swapBytes);<br>
...<br>
bytesToShift = memStart - oldBaseAddr;<br>
<br>
<br>
Thanks.<br>
<br>
Ang Beepeng<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/oldBaseAddr-tp25120957p25120957.html" target="_blank">http://www.nabble.com/oldBaseAddr-tp25120957p25120957.html</a><br>
Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
<br>
</font></blockquote></div><br></div>