Ok, well there is a number of optimizations on the os-x and iphone VM code that I should explain. I choose 500M as a start value because then I can save an image with an os-x based VM and move it to the iPhone without having the oops pointer logic wanting to reset all the oops offset values, ie if the saved start of memory is the same as the new start of memory then we skip the oops reset. <div>
<br></div><div>On the iPhone the mmap logic  maps ram memory to the flash memory pages of the image, so if you don&#39;t touch the ram then it doesn&#39;t swap the page from flash into ram.  So if you avoid doing the oops pointer reset, and the dozen or so allInstances that occur that at image startup time, then you avoid 2 or 3 seconds of clock time that was taken to swap in oops pages from flash to ram (for no purpose).  This could be fixed if you could create images that only contain objects that are actually used, but that problem is hard to solve.</div>
<div><br></div><div>For the iPhone I could make the image file mmap writable, but by design image files are read-only, although I could make a writable copy, but was unsure of issues of crashes and what state the image file would be in. Well I could set a flag, but this issue is less important now from the days when an iphone had only about 64MB of ram to work with, versus the 150MB in an iphone 3GS. Still I might revisit this since it technically provides virtual memory backing to storage (flash) if ram becomes constraint.</div>
<div><br></div><div>For os-x and the iphone if you look closer I did mmap the image file bytes into space starting at 500MB, but then I mmaped anonymous memory after the end of the image file to the upper limit. That works quite well on the iphone and on testing on an older powerbook 3400 showed an interesting time/work curves as it pages in the oops pages, but we discovered that this particular setup does not properly work on NFS mounted volumes so the logic is turned off on os-x. Although there is a flag to enable it if you wish to shave a few 100ms off the os-x vm startup time. Otherwise on os-x we just dump the image file data into mmap memory via an fread() Yes mmap was faster (but faulty), and on os-x it would (unlike iphone) swap in all the image file pages at once.</div>
<div><br></div><div><br></div><div><br><div class="gmail_quote">On Tue, May 11, 2010 at 10:54 PM, Javier Pimás <span dir="ltr">&lt;<a href="mailto:elpochodelagente@gmail.com">elpochodelagente@gmail.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>The heap is at a virtual address that depends on the platform. Many platforms try to put it starting at a fixed virtual address (like 500M or 512M). Unix doesn&#39;t bother. </blockquote>
</div>
</div>