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? 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? 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. 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 |
On 4 May 2010 16:12, Mariano Martinez Peck <[hidden email]> 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/win32/vm/sqwin32alloc.c platforms/unix/vm/squnixmemory.c 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. |
In reply to this post by Mariano Martinez Peck
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: > > 1) Is the same behavior for all OS ? If not, which happens with the rest? > > 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? > > 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. > > 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 |
http://isqueak.org/sqAllocateMemory http://isqueak.org/sqGrowMemoryBy http://isqueak.org/sqShrinkMemoryBy http://isqueak.org/sqMemoryExtraBytesLeft That said, there are some issues which can defeat your vision of only working with part of the oops space (a) I can't remember if this was removed, but at startup time we would iterate over the oops space confirming the setting of the root bit to fix a problem related to images created in mm what 1992? This should not be a concern for closure based images since cleanup code at image save time fixed the issue and was introduced 10 or so years ago. (b) If you invoke allInstances it ends up iterating over the entire oops space, you'll find there are a dozen or so uses of that pattern in the image that are triggered via startup: (c) If your oops space start address isn't the same as it was when you saved the image, then the vm will iterate over all the oops readjusting the oops address to the start address offset. Adjusting the platforms Virtual memory mapping system to place the oops space at 512MB helps avoid that. (d) The untuned GC will at some point invoke a full GC if you don't adjust it to bias against full GC activity. Given all that then for example for WikiServer for the iPhone where the operating system does not pre-load virtual memory mapped pages and where I've removed the desire to do allInstances and tuned the GC not to do a full GC at the drop of a hat. Then that results in a image that spans 1,932 4K pages (7,913,472), of which 806 pages (3,301,376) are swapped in from Flash, and 68 pages are modified to get the first wiki page visible. This means 4,612,096 bytes are left in Flash, which on a iPhone 3G shaves 2 or 3 seconds off the startup time. On 2010-05-04, at 7:56 AM, Andreas Raab wrote: > 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: >> >> 1) Is the same behavior for all OS ? If not, which happens with the rest? >> >> 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? >> >> 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. >> >> 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 =========================================================================== John M. McIntosh <[hidden email]> Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com =========================================================================== smime.p7s (3K) Download Attachment |
Ok....a completely new world to explore for me. I was just thinking about this but maybe I will have to "do it" in a couple of months. I will be slowly reading and analyzing each of your comments and I will ask any further question. Thanks to everybody. Mariano On Tue, May 4, 2010 at 6:22 PM, John M McIntosh <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |