Look at memory mapping (mmap on unix, MapViewOfFile on Windows). What you're describing can be done simply by mapping and unmapping memory regions from an image file. I believe the iPhone does just that.
Cheers, - Andreas
On 5/4/2010 6:12 AM, Mariano Martinez Peck wrote:
Sorry in advance if this was asked before...I have something in my mind that says it was :(
I want to know how the memory is allocated between the VM and the OS. For example, I know (actually, I think I know) that in Mac OS VM when you run an image, the VM allocates (malloc() I guess) the same size at least, of the image. So...I couple of questions:
Is the same behavior for all OS ? If not, which happens with the rest?
Where is such behavior defined? I don't think it is in VMMaker but in
the C support code of each VM. But where (.c and function anme) , any quotes?
- In am working (actually yet thinking) a mechanism that will probably
use much less memory than the image. The idea is to swap to disk unused objects. Then....the amount of memory I will use should be MUCH smaller than the size of the image. So my question is, which changes should I do to the VM so that it uses only THAT amount of memory and not the size of the image.
As I said, suppose I have an image size (in disk) on 15MB. Suppose I run that image, and then, as I swapped a lot of objects to disk, the actual usage of memory is 3 MBs. So what I want is that OS only uses 3 MB and not 15. Can I do that ?
Thanks a lot for answering to this newbie :)
Mariano