<br><br><div class="gmail_quote">On Mon, Aug 24, 2009 at 12:48 PM, 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>
Thank you very much.<br>
<br>
Do you mean that during squeak start-up, process of memory allocation<br>
somehow make memStart to have value according to the image loaded. And<br>
therefore the same as oldBaseAddr which is  from the same image.<br>
(I know very little about memory allocation in every aspect, sorry about<br>
that)<br>
</blockquote><div><br></div><div>No.  The issue is that memStart is where the OS gives it to you.  It could be anywhere.  It could also change between two slightly different VMs on the same platform, because one VM might have more code and therefore memStart would end up at a higher address.</div>
<div><br></div><div>So the problem is to load the image at the address that the OS gives you memory in which to load the heap.  Writing oldBaseAddr to the image avoids having to update the pointers when writing the image.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
The difference is only when one reload a snapshot, without restarting the<br>
VM. memStart remain the same, but oldBaseAddr (memStart of another snaphot)<br>
is different. Is that correct?</blockquote><div><br></div><div>The other way around.  oldBaseAddr is the base of the heap at the time the snapshot was written.  memStart is the start of the heap in the current system that is trying to load the snapshot.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
Thanks.<br>
<br>
Ang Beepeng<br>
<div class="im"><br>
<br>
Eliot Miranda-2 wrote:<br>
&gt;<br>
&gt; Hi Ang,<br>
&gt;     when a snapshot is written the heap is simply written to the file, so<br>
&gt; all the object addresses in the file are those the objects had in the<br>
&gt; address space of the process that wrote the snapshot.  The start address<br>
&gt; of<br>
&gt; the heap is written to the snapshot file&#39;s header in the oldBaseAddr<br>
&gt; field.<br>
&gt;  So nil, which is the first object in the heap, has address oldBaseAddr.<br>
&gt; So<br>
&gt; nil&#39;s address - oldBaseAddr is zero.  i.e. subtracting oldBaseAddr<br>
&gt; converts<br>
&gt; an absolute heap address into a releative one where the heap starts at 0.<br>
&gt;<br>
&gt; When a snapshot is loaded, the VM asks the OS to allocate memory for the<br>
&gt; heap and assigns the start of this memory to memStart.  Therefore to load<br>
&gt; a<br>
&gt; snapshot file at the new address, memStart, all pointers in the heap must<br>
&gt; be<br>
&gt; adjusted by memStart - oldBaseAddr.<br>
&gt;<br>
&gt; HTH<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div><font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/oldBaseAddr-tp25120957p25122722.html" target="_blank">http://www.nabble.com/oldBaseAddr-tp25120957p25122722.html</a><br>
</font><div><div></div><div class="h5">Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
<br>
</div></div></blockquote></div><br>