[Vm-dev] Question about memory allocation in VM

Igor Stasenko siguctua at gmail.com
Tue May 4 14:19:10 UTC 2010

On 4 May 2010 16:12, Mariano Martinez Peck <marianopeck at gmail.com> 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:
> 1) Is the same behavior for all OS ? If not, which happens with the rest?
Windows using VirtualAlloc, and Linux - mmap. Both allocating a
virtual memory, not malloc().
For macs, i don't sure, since i don't have mac :)

> 2) 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?
platforms/Mac OS/vm/sqmacmemory.c

> 3) 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.
you certaintly will need the virtual memory, so you can swap unused
pages to disk.

> 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

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list