• Virtual memory size (OSX.4.6) ?

    From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Saturday, April 08, 2006 19:27:42
    From Newsgroup: comp.sys.mac.system

    Hi all,

    I have a problem understanding how virtual memory is counted :
    - The activity monitor shows 4.36GB of Virtual memory
    - /private/var/vm/swapfile* files have a total size of 512MB
    I verified that these are really the active swapfiles.
    There are 59 processes, a dozen of which are displayed as "active".

    So what does the Virtual Memory mean ? Is it the maximum size that an application could claim ? Or is this VM heavily compressed ?

    As for RAM, the match is good, my 512MB are almost fully used...
    Powerbook G4/667, OSX.4.6, 512MB RAM

    Thanks in advance for your ideas...

    Claude-Albert
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From see_signature@see_signature@mac.com.invalid (Jon) to comp.sys.mac.system on Saturday, April 08, 2006 19:35:06
    From Newsgroup: comp.sys.mac.system

    Claude-Albert Berseth <void@nospam.com> wrote:

    As for RAM, the match is good, my 512MB are almost fully used...
    Powerbook G4/667, OSX.4.6, 512MB RAM

    Before all the others start explaining things: Get more RAM!
    IMHO, no Mac should hve less than 768, preferably 1GB or more. It will
    do wonders to performance and response. VM is slo-o-o-ow in comparison
    with real RAM, no matter what you do, and the less the Mac needs to
    utilize it (i.e., swap in and out) the better.
    --
    /Jon
    For mail address, run the following in Terminal:
    echo 36199371860304980107073482417748002696458P|dc
    Skype: storhaugen
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Saturday, April 08, 2006 20:25:32
    From Newsgroup: comp.sys.mac.system

    Jon wrote:
    Claude-Albert Berseth <void@nospam.com> wrote:

    As for RAM, the match is good, my 512MB are almost fully used...
    Powerbook G4/667, OSX.4.6, 512MB RAM

    Before all the others start explaining things: Get more RAM!
    IMHO, no Mac should hve less than 768, preferably 1GB or more. It will
    do wonders to performance and response. VM is slo-o-o-ow in comparison
    with real RAM, no matter what you do, and the less the Mac needs to
    utilize it (i.e., swap in and out) the better.

    Sure enough, Jon. I ordered 1GB a few days ago, I can't wait to see
    the improvement !!!
    I think 512MB was ok (sort of) up to X.1 or X.2 but the system has
    become very heavy since then ...
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From haberg@haberg@math.su.se (Hans Aberg) to comp.sys.mac.system on Saturday, April 08, 2006 18:39:44
    From Newsgroup: comp.sys.mac.system

    In article <c7681$4437f288$5448a851$21543@news.hispeed.ch>, Claude-Albert Berseth <void@nospam.com> wrote:

    I have a problem understanding how virtual memory is counted :

    Just forget about it - it is too complicated. :-)

    So what does the Virtual Memory mean ? Is it the maximum size that an application could claim ? Or is this VM heavily compressed ?

    Mac OS X has BSD UNIX at the bottom, which divides the RAM into pages,
    which each, I think is 1 kB. When RAM is getting short, pages that are
    thought to be less active by the OS are swapped onto the hard disk. Each program has a number of active data sections, each which can hold a
    virtual memory byte map of the maximum address space, which is 2^31 bytes, which comes from the fact that one uses 32-bit addressing, and reserves
    one bit for a sign. The UNIX kernel makes each program think it has all
    that memory available, even though in practice it is limited to hard disk
    size.

    Now, this stuff is not very important to you as a user, because it is
    hidden away. What is important to you and other users, is to ensure that
    the active program parts are kept in RAM and not swapped out on the hard
    disk, because the hard drive is about a hundred times slower than the RAM.
    So if you have too little RAM, your computer will slow down enormously, as
    it will spend all its time waiting for hard drive accesses to finish.

    If you go into the utility Activity Monitor/System Memory, the Page Outs
    field at the bottom, and get a lot of those when you are swapping
    programs, then you have too little RAM. The same if trying to conduct an operation within a program. The RAM is then too short, as it means that
    normal user operations will cause active program parts (pages) to become swapped out on the hard disk: only those that are relatively inactive
    should be swapped out, for the OS to be able to work efficiently. So then
    you need to get hold of more RAM, or alternatively, have a lot of patience while working with your computer. :-)

    --
    Hans Aberg
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From nonesuch@nonesuch@place.com (Adrian) to comp.sys.mac.system on Saturday, April 08, 2006 21:12:04
    From Newsgroup: comp.sys.mac.system

    Claude-Albert Berseth <void@nospam.com> wrote:

    Sure enough, Jon. I ordered 1GB a few days ago, I can't wait to see
    the improvement !!!
    I think 512MB was ok (sort of) up to X.1 or X.2 but the system has
    become very heavy since then ...

    Be sure to post your findings. I have always had an unnatural desire for
    lots of RAM myself (!) but I am also aware of situations where the much
    vaunted speed benefits haven't been particularly evident to some people
    after an increase (depending on their applications usage, of course).


    --
    Adrian
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Bob Harris@nospam.News.Bob@remove.Smith-Harris.us to comp.sys.mac.system on Sunday, April 09, 2006 00:10:20
    From Newsgroup: comp.sys.mac.system

    In article <c7681$4437f288$5448a851$21543@news.hispeed.ch>,
    Claude-Albert Berseth <void@nospam.com> wrote:

    Hi all,

    I have a problem understanding how virtual memory is counted :
    - The activity monitor shows 4.36GB of Virtual memory
    - /private/var/vm/swapfile* files have a total size of 512MB
    I verified that these are really the active swapfiles.
    There are 59 processes, a dozen of which are displayed as "active".

    So what does the Virtual Memory mean ? Is it the maximum size that an application could claim ? Or is this VM heavily compressed ?

    As for RAM, the match is good, my 512MB are almost fully used...
    Powerbook G4/667, OSX.4.6, 512MB RAM

    Thanks in advance for your ideas...

    Claude-Albert

    Hans was very close, except a page is 4K, not 1K.

    An analogy for Virtual Memory is using one of the those Rental
    Storage Facilities. When you have to much stuff in your house and
    you move it to the storage facility, it is slow to get there, and
    slow to come back home. If you keep bringing more stuff home,then
    you rent more space. And you can not forget about it because your
    spouse is a task master that will not let you :-)

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    If all you are seeing is zeros when doing things or when you feel
    the system is slow, then you do not need more memory.

    If during slow times, you are seeing single digit numbers or maybe
    very low double digit numbers, then yes you are paging and
    swaping, but the demand is not all that high.

    If you are getting high double digit or triple (or dare I say 4
    digit) pageout numbers, then you are very severely low on memory.

    Note a momentary burst of pageout from time to time is not big
    deal. If you get some pageout when you start a new application,
    or when you switch between applications (assuming you are not
    switching back and forth constantly), then this is not worth
    worrying about.

    The pageout column is the best measure of low memory vs needs. If
    you are getting zeros or very low and it still feels slow, then
    you can look one column to the left at the pagein. However, be
    warned that when you launch a program the program will be loaded
    into memory via pagein. So you will always have pagein activity
    when starting a program or when that program uses a new function
    where the code has not been used before (like applying a new color
    filter in a graphic program, as an example).

    But if you have consistent moderate or high pagein activity, then
    this might indicate more memory could be of use.

    Finally, if the cost of more memory is not an issue, then buy it
    (assuming you don't already have 4GB of memory already :-)

    Bob Harris
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From haberg@haberg@math.su.se (Hans Aberg) to comp.sys.mac.system on Sunday, April 09, 2006 04:55:13
    From Newsgroup: comp.sys.mac.system

    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob
    Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Hans was very close, except a page is 4K, not 1K.

    How do you check this virtual memory page size via some UNIX command?

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    It seems that one has to install the developer package, for 'vm_stat' to
    be present. Using 'vm_stat' otherwise gives a convenient way to check it.
    In order to install the developer package, go to the Apple developer site
    and download latest Xcode, and install it directly; do not do install the developer package from the install disks, as the updating is buggy.

    --
    Hans Aberg
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Sunday, April 09, 2006 12:49:29
    From Newsgroup: comp.sys.mac.system

    Hans Aberg wrote:
    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Hans was very close, except a page is 4K, not 1K.

    How do you check this virtual memory page size via some UNIX command?

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    It seems that one has to install the developer package, for 'vm_stat' to
    be present. Using 'vm_stat' otherwise gives a convenient way to check it.
    In order to install the developer package, go to the Apple developer site
    and download latest Xcode, and install it directly; do not do install the developer package from the install disks, as the updating is buggy.


    Ok, vm_stat works and I have started to watch the pageouts. It will take
    me some time to get a good feeling. For the moment I see a very low
    level of pageouts, bursts of pageins when bringing an app to the front
    or starting a new command - as expected.

    As for my initial question, I still don't understand the meaning of the "Virtual Memory" size for each application. It ranges from 20MB to 200MB
    for most of my apps, with Firefox having 479MB and the kernel 652MB.
    Note that these sizes seem to be dynamic, for example adding a tab and
    opening another web page in Firefox makes its VM size increase.
    But...is Firefox really using up 479MB (RAM or paged out, I don't care)
    ??? Or is this just an allocation in case Firefox would need that space ?
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Bob Harris@nospam.News.Bob@remove.Smith-Harris.us to comp.sys.mac.system on Sunday, April 09, 2006 14:13:30
    From Newsgroup: comp.sys.mac.system

    In article
    <haberg-0904060655130001@c83-250-195-81.bredband.comhem.se>,
    haberg@math.su.se (Hans Aberg) wrote:

    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Hans was very close, except a page is 4K, not 1K.

    How do you check this virtual memory page size via some UNIX command?

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    It seems that one has to install the developer package, for 'vm_stat' to
    be present. Using 'vm_stat' otherwise gives a convenient way to check it.
    In order to install the developer package, go to the Apple developer site
    and download latest Xcode, and install it directly; do not do install the developer package from the install disks, as the updating is buggy.

    I just picked it up along the way. I've been developing kernel
    code for so many years on so many different UNIX based platforms,
    that I pick this stuff up as it passes by in news groups,
    processor specs, manuals, etc... (none of which have been Macs,
    unfortunately :-) )

    But I did a little digging in the man pages, and the "man vmmap"
    command (never used it personally), says pages are displayed in
    "4KB pages". While it does not say flat out that a VM page is 4K,
    it is at least reinforcement for it.

    Also 4K is a very common VM page size in many operating systems.

    Best I can do at the moment.

    Bob Harris
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Sunday, April 09, 2006 16:53:00
    From Newsgroup: comp.sys.mac.system

    Bob Harris wrote:


    But I did a little digging in the man pages, and the "man vmmap"
    command (never used it personally), says pages are displayed in
    "4KB pages". While it does not say flat out that a VM page is 4K,
    it is at least reinforcement for it.

    Also 4K is a very common VM page size in many operating systems.

    Best I can do at the moment.

    Bob Harris

    Bob,

    When executing the command vm_stat, here is what I get (3 first lines) :

    Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 70%)
    free active inac wire faults copy zerofill reactive pageins
    pageout
    3604 67934 40567 18967 7622458 120565 5607432 152336 65303
    51358
    3569 71555 40602 15346 10970 12 7950 0 0
    0


    I think the page size is unequivocally shown...
    Claude-Albert
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Bob Harris@nospam.News.Bob@remove.Smith-Harris.us to comp.sys.mac.system on Sunday, April 09, 2006 14:54:36
    From Newsgroup: comp.sys.mac.system

    In article <281e1$4438e6ba$5448a851$6667@news.hispeed.ch>,
    Claude-Albert Berseth <void@nospam.com> wrote:

    Hans Aberg wrote:
    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Hans was very close, except a page is 4K, not 1K.

    How do you check this virtual memory page size via some UNIX command?

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    It seems that one has to install the developer package, for 'vm_stat' to
    be present. Using 'vm_stat' otherwise gives a convenient way to check it. In order to install the developer package, go to the Apple developer site and download latest Xcode, and install it directly; do not do install the developer package from the install disks, as the updating is buggy.


    Ok, vm_stat works and I have started to watch the pageouts. It will take
    me some time to get a good feeling. For the moment I see a very low
    level of pageouts, bursts of pageins when bringing an app to the front
    or starting a new command - as expected.

    As for my initial question, I still don't understand the meaning of the "Virtual Memory" size for each application. It ranges from 20MB to 200MB
    for most of my apps, with Firefox having 479MB and the kernel 652MB.
    Note that these sizes seem to be dynamic, for example adding a tab and opening another web page in Firefox makes its VM size increase.
    But...is Firefox really using up 479MB (RAM or paged out, I don't care)
    ??? Or is this just an allocation in case Firefox would need that space ?

    The operating system creates a Virtual Memory map for an
    application when it is created based on the size of the
    executable, the size of the initialized data (text strings,
    constants, variables initialized by the compiler, etc...), and the
    declared uninitialized memory needs of the program (both data and
    stack space). This is also done for any run-time libraries the
    program may have been linked against. This results in a Virtual
    Map of the potential memory needs for the appliations, BUT NOT ONE
    BIT OF MEMORY HAS BEEN GIVEN TO THE APPLICATION YET. All of this
    is just book keeping by the OS. Like drawing up the plans for a
    house before you build it.

    This is the initial Virtual Memory for an application and it will
    vary depending on how much code, initialized data, declared
    uninitialized data, and libraries the application programs uses.
    Small programs use less VM up front than huge mega programs.

    Now as the applications is launched code and data are paged into
    memory from the application file and the run-time libraries. Real
    memory is allocated to the applications at this time, but only for
    areas that used. Until they are used, they sit out on disk
    waiting.

    In addition, the program will start to use the uninitialized
    memory areas it declared during compile time, and real memory will
    be allocated as the virtual address space is used.

    An application may dynamically allocation additional memory as it
    run (for example Firefox may dynamically allocate cache to store
    web pages and images in). This dynamic allocation causes the
    operating system to allocate additional virtual memory space to
    the application, so the applications VM size can grow.

    This dynamic allocation is like building an addition onto your
    house. It was not in the original plans, but you do it anyway. A
    garage, back deck, room over the garage, family room, sun room,
    wrap around porch, tool shed, swimming pool, flower garden,
    vegetable garden, etc...

    Applications programs can dynamically load additional code, that
    were not there to begin with. Plugins, extensions, additional
    libraries. For example, Firefox may load a plugin or extension to
    run Flash, or Java. But until it downloads a page that needs
    those services it will not bother. But each of these plugins,
    extensions, libraries will require additional Virtual Memory
    address space, so the applications VM size will grow some more.

    Finally, some applications have memory leaks. Those of us in
    programming don't like to air our dirty laundry in public, but it
    does happen. In this case an application with a memory leak will
    dynamically allocate memory, and sometimes forget to free it for
    reuse. As time goes by it forgets more and more dynamica memory,
    and grows to a very large VM size. Quiting such an application
    will free up all the VM.

    Now having mentioned Memory Leaks, I am _NOT_ saying anything
    about Firefox. For the most part Firefox is just using more VM
    because over time it caches more web pages and images, you open
    more tabs, you eventually load a page with java on it, you
    eventually load a page with Flash, you get around to loading a
    page with Quicktime needs (video or audio), etc... and Firefox
    dynamically allocates more memory.

    OK, now if you have lots and lots of memory, then as your
    application uses the VM, real memory is allocated to it, and
    everything is great.

    But generally more real memory will be needed than physically
    exists, and the operating system will now start to page.

    First it will look for pages that are inactive. The OS keeps tabs
    on the usage of Real memory, and if an application loaded a
    section of code or data awhile ago, but has not used it recently,
    that memory will be marked inactive. Inactive pages of Real
    memory that are read-only and have original copies on disk (like
    application or library code), are easy cheap sources of additional
    memory, as the OS just needs to mark the VM map to say the
    application program needs to get this from disk if it needs it
    again, and then just give the memory to the task that is in need.

    This is one of the ways you will see an application program pagein
    data when you switch to it. It was idle while you were away,
    pages became inactive, eventually the inactive pages were needed
    for something else, so the read-only pages were released for other
    needs.

    Inactive memory that has been modified, need to be paged out
    before the memory can be used. Even if there is an original on
    disk, you do not use that as the modified values are not the
    original values, so space in the page files is allocated, and
    these pages are paged out. (if the page was paged out before,
    then it already has a space in the page file, and will just be
    paged back to that space).

    These paged out pages are also a source of pagein activity, when
    you switch to an app. The big difference is that you paid the
    price of paging it out and paging it in.

    Also when you start paging out, there is a very good likely hood
    that you may soon reach the point when you application is paging
    against itself. That is to say the application is so big and
    doing so much work on so much data, that it is not longer getting
    pages from other idle applications, it needs to get pages from
    itself. Of course the application doesn't know that, the OS makes
    decisions and if there is no other memory to free, it will start
    to take if from active page of the application itself. This is
    generally the case when you are seeing constant paging. It can
    also happen if you have several active applications running
    concurrently, like playing iTunes while doing software update,
    while surfing the web, while downloading email, while Photoshop
    runs a complex filter, while using iChat video session with your
    Mom, etc... Then everyone is stealing pages from everyone else.

    So did I loose you on the 2nd paragraph? Or is everything "Clear
    as Mug"?

    Bob Harris
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Tim Lance@lance_1012@hotmail.com to comp.sys.mac.system on Sunday, April 09, 2006 10:44:12
    From Newsgroup: comp.sys.mac.system

    On Sun, 9 Apr 2006 09:54:36 -0500, Bob Harris wrote
    (in article <nospam.News.Bob-7A6EDE.10545609042006@news.verizon.net>):

    In article <281e1$4438e6ba$5448a851$6667@news.hispeed.ch>,
    Claude-Albert Berseth <void@nospam.com> wrote:

    Hans Aberg wrote:
    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob >>> Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Hans was very close, except a page is 4K, not 1K.

    How do you check this virtual memory page size via some UNIX command?

    My preferred way of figuring out if you are suffering from too
    little memory is to launch Applications -> Utilities -> Terminal
    then run the program 'vm_stat 60' and watch the last column
    (pageout) ignoring the first row after the descriptive header line.

    It seems that one has to install the developer package, for 'vm_stat' to >>> be present. Using 'vm_stat' otherwise gives a convenient way to check it. >>> In order to install the developer package, go to the Apple developer site >>> and download latest Xcode, and install it directly; do not do install the >>> developer package from the install disks, as the updating is buggy.


    Ok, vm_stat works and I have started to watch the pageouts. It will take
    me some time to get a good feeling. For the moment I see a very low
    level of pageouts, bursts of pageins when bringing an app to the front
    or starting a new command - as expected.

    As for my initial question, I still don't understand the meaning of the
    "Virtual Memory" size for each application. It ranges from 20MB to 200MB
    for most of my apps, with Firefox having 479MB and the kernel 652MB.
    Note that these sizes seem to be dynamic, for example adding a tab and
    opening another web page in Firefox makes its VM size increase.
    But...is Firefox really using up 479MB (RAM or paged out, I don't care)
    ??? Or is this just an allocation in case Firefox would need that space ?

    The operating system creates a Virtual Memory map for an
    application when it is created based on the size of the
    executable, the size of the initialized data (text strings,
    constants, variables initialized by the compiler, etc...), and the
    declared uninitialized memory needs of the program (both data and
    stack space). This is also done for any run-time libraries the
    program may have been linked against. This results in a Virtual
    Map of the potential memory needs for the appliations, BUT NOT ONE
    BIT OF MEMORY HAS BEEN GIVEN TO THE APPLICATION YET. All of this
    is just book keeping by the OS. Like drawing up the plans for a
    house before you build it.

    This is the initial Virtual Memory for an application and it will
    vary depending on how much code, initialized data, declared
    uninitialized data, and libraries the application programs uses.
    Small programs use less VM up front than huge mega programs.

    Now as the applications is launched code and data are paged into
    memory from the application file and the run-time libraries. Real
    memory is allocated to the applications at this time, but only for
    areas that used. Until they are used, they sit out on disk
    waiting.

    In addition, the program will start to use the uninitialized
    memory areas it declared during compile time, and real memory will
    be allocated as the virtual address space is used.

    An application may dynamically allocation additional memory as it
    run (for example Firefox may dynamically allocate cache to store
    web pages and images in). This dynamic allocation causes the
    operating system to allocate additional virtual memory space to
    the application, so the applications VM size can grow.

    This dynamic allocation is like building an addition onto your
    house. It was not in the original plans, but you do it anyway. A
    garage, back deck, room over the garage, family room, sun room,
    wrap around porch, tool shed, swimming pool, flower garden,
    vegetable garden, etc...

    Applications programs can dynamically load additional code, that
    were not there to begin with. Plugins, extensions, additional
    libraries. For example, Firefox may load a plugin or extension to
    run Flash, or Java. But until it downloads a page that needs
    those services it will not bother. But each of these plugins,
    extensions, libraries will require additional Virtual Memory
    address space, so the applications VM size will grow some more.

    Finally, some applications have memory leaks. Those of us in
    programming don't like to air our dirty laundry in public, but it
    does happen. In this case an application with a memory leak will dynamically allocate memory, and sometimes forget to free it for
    reuse. As time goes by it forgets more and more dynamica memory,
    and grows to a very large VM size. Quiting such an application
    will free up all the VM.

    Now having mentioned Memory Leaks, I am _NOT_ saying anything
    about Firefox. For the most part Firefox is just using more VM
    because over time it caches more web pages and images, you open
    more tabs, you eventually load a page with java on it, you
    eventually load a page with Flash, you get around to loading a
    page with Quicktime needs (video or audio), etc... and Firefox
    dynamically allocates more memory.

    OK, now if you have lots and lots of memory, then as your
    application uses the VM, real memory is allocated to it, and
    everything is great.

    But generally more real memory will be needed than physically
    exists, and the operating system will now start to page.

    First it will look for pages that are inactive. The OS keeps tabs
    on the usage of Real memory, and if an application loaded a
    section of code or data awhile ago, but has not used it recently,
    that memory will be marked inactive. Inactive pages of Real
    memory that are read-only and have original copies on disk (like
    application or library code), are easy cheap sources of additional
    memory, as the OS just needs to mark the VM map to say the
    application program needs to get this from disk if it needs it
    again, and then just give the memory to the task that is in need.

    This is one of the ways you will see an application program pagein
    data when you switch to it. It was idle while you were away,
    pages became inactive, eventually the inactive pages were needed
    for something else, so the read-only pages were released for other
    needs.

    Inactive memory that has been modified, need to be paged out
    before the memory can be used. Even if there is an original on
    disk, you do not use that as the modified values are not the
    original values, so space in the page files is allocated, and
    these pages are paged out. (if the page was paged out before,
    then it already has a space in the page file, and will just be
    paged back to that space).

    These paged out pages are also a source of pagein activity, when
    you switch to an app. The big difference is that you paid the
    price of paging it out and paging it in.

    Also when you start paging out, there is a very good likely hood
    that you may soon reach the point when you application is paging
    against itself. That is to say the application is so big and
    doing so much work on so much data, that it is not longer getting
    pages from other idle applications, it needs to get pages from
    itself. Of course the application doesn't know that, the OS makes
    decisions and if there is no other memory to free, it will start
    to take if from active page of the application itself. This is
    generally the case when you are seeing constant paging. It can
    also happen if you have several active applications running
    concurrently, like playing iTunes while doing software update,
    while surfing the web, while downloading email, while Photoshop
    runs a complex filter, while using iChat video session with your
    Mom, etc... Then everyone is stealing pages from everyone else.

    So did I loose you on the 2nd paragraph? Or is everything "Clear
    as Mug"?

    Bob Harris

    What a great explanation. Thank you.

    --

    Tim
    lance_1012@hotmail.com

    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Andre Berger@andre.berger@web.de to comp.sys.mac.system on Sunday, April 09, 2006 17:45:08
    From Newsgroup: comp.sys.mac.system

    * Bob Harris (2006-04-09):
    In article <281e1$4438e6ba$5448a851$6667@news.hispeed.ch>,
    Claude-Albert Berseth <void@nospam.com> wrote:

    Hans Aberg wrote:
    In article <nospam.News.Bob-A49663.20103908042006@news.verizon.net>, Bob Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:
    [snip]
    So did I loose you on the 2nd paragraph? Or is everything "Clear
    as Mug"?

    Bob, you're awesome. Thank you so much.

    -Andre
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Ilgaz Ocal@ilgaz_ocal@yahoo.com to comp.sys.mac.system on Sunday, April 09, 2006 19:06:40
    From Newsgroup: comp.sys.mac.system

    On 2006-04-08 21:25:32 +0300, Claude-Albert Berseth <void@nospam.com> said:

    Sure enough, Jon. I ordered 1GB a few days ago, I can't wait to see
    the improvement !!!
    I think 512MB was ok (sort of) up to X.1 or X.2 but the system has
    become very heavy since then ...

    Yes, Apple never "wastes" additional RAM, even if it is not used, it
    will be used for all sorts of "cache" stuff.

    I use 1.5 GB for years and had excellent performance as result of it.

    BTW, you may see "64mb" or "128mb" of "swap" still used after having
    those RAMs installed. It is part of "OS Strategy". Common in all modern
    OS'es.

    In fact I will move to 4 gb with my G5 dual 2300 (when I finally buy),
    they will get used anyway :)

    Ilgaz

    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Sunday, April 09, 2006 18:12:19
    From Newsgroup: comp.sys.mac.system

    Bob Harris wrote:

    So did I loose you on the 2nd paragraph? Or is everything "Clear
    as Mug"?

    Bob Harris

    Bob,

    Thanks for taking the time to write this excellent tutorial !

    Playing a bit with the applications I finally get to the point where
    frequent paging is seen. But not (yet) paging against self...

    Concerning Thunderbird I don't think there is an issue : closing tabs
    with heavy contents or clearing the cache result in shrinking of the VM
    size (I now see 172MB).
    For the moment I don't see much activity on the swapfiles (which I also
    moved to a non-system partition, I hope this will also relieve the
    system partition).

    Claude-Albert
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Claude-Albert Berseth@void@nospam.com to comp.sys.mac.system on Sunday, April 09, 2006 18:17:16
    From Newsgroup: comp.sys.mac.system

    Ilgaz Ocal wrote:
    On 2006-04-08 21:25:32 +0300, Claude-Albert Berseth <void@nospam.com> said:

    Sure enough, Jon. I ordered 1GB a few days ago, I can't wait to see
    the improvement !!!
    I think 512MB was ok (sort of) up to X.1 or X.2 but the system has
    become very heavy since then ...

    Yes, Apple never "wastes" additional RAM, even if it is not used, it
    will be used for all sorts of "cache" stuff.

    I use 1.5 GB for years and had excellent performance as result of it.

    BTW, you may see "64mb" or "128mb" of "swap" still used after having
    those RAMs installed. It is part of "OS Strategy". Common in all modern OS'es.

    In fact I will move to 4 gb with my G5 dual 2300 (when I finally buy),
    they will get used anyway :)

    Ilgaz

    Hi Ilgaz,
    The maximum possible RAM on my PB G4/667 is 1 GB. Well, I believe by the
    time I need more than 1GB I might also be limited by processor speed. Claude-Albert
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From haberg@haberg@math.su.se (Hans Aberg) to comp.sys.mac.system on Sunday, April 09, 2006 16:59:48
    From Newsgroup: comp.sys.mac.system

    In article <nospam.News.Bob-7A6EDE.10545609042006@news.verizon.net>, Bob
    Harris <nospam.News.Bob@remove.Smith-Harris.us> wrote:

    Finally, some applications have memory leaks. Those of us in
    programming don't like to air our dirty laundry in public, but it
    does happen. In this case an application with a memory leak will dynamically allocate memory, and sometimes forget to free it for
    reuse. As time goes by it forgets more and more dynamica memory,
    and grows to a very large VM size. Quiting such an application
    will free up all the VM.

    I think one will find that most programs have leaks, especially if written
    in a program language that does not support cleanup for you. Therefore, I
    think it is safest to restart programs every once in awhile, that is, do
    not let them run for weeks, unless you are sure it is a program
    specifically written to be run indefinitely.

    --
    Hans Aberg
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From haberg@haberg@math.su.se (Hans Aberg) to comp.sys.mac.system on Sunday, April 09, 2006 17:01:41
    From Newsgroup: comp.sys.mac.system

    In article <5ae8c$44391fcc$5448a851$20117@news.hispeed.ch>, Claude-Albert Berseth <void@nospam.com> wrote:

    When executing the command vm_stat, here is what I get (3 first lines) :

    Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 70%)

    Thanks. I should perhaps have run 'vm_stat' before asking, but know
    everyone knows, which is good. :-)

    --
    Hans Aberg
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Paul Sture@paul.sture.nospam@hispeed.ch to comp.sys.mac.system on Sunday, April 09, 2006 22:20:15
    From Newsgroup: comp.sys.mac.system

    Bob Harris wrote:


    The operating system creates a Virtual Memory map for an
    application when it is created based on the size of the
    executable, the size of the initialized data (text strings,
    constants, variables initialized by the compiler, etc...), and the
    declared uninitialized memory needs of the program (both data and
    stack space). This is also done for any run-time libraries the
    program may have been linked against. This results in a Virtual
    Map of the potential memory needs for the appliations, BUT NOT ONE
    BIT OF MEMORY HAS BEEN GIVEN TO THE APPLICATION YET. All of this
    is just book keeping by the OS. Like drawing up the plans for a
    house before you build it.

    This is the initial Virtual Memory for an application and it will
    vary depending on how much code, initialized data, declared
    uninitialized data, and libraries the application programs uses.
    Small programs use less VM up front than huge mega programs.

    Now as the applications is launched code and data are paged into
    memory from the application file and the run-time libraries. Real
    memory is allocated to the applications at this time, but only for
    areas that used. Until they are used, they sit out on disk
    waiting.

    In addition, the program will start to use the uninitialized
    memory areas it declared during compile time, and real memory will
    be allocated as the virtual address space is used.

    An application may dynamically allocation additional memory as it
    run (for example Firefox may dynamically allocate cache to store
    web pages and images in). This dynamic allocation causes the
    operating system to allocate additional virtual memory space to
    the application, so the applications VM size can grow.

    This dynamic allocation is like building an addition onto your
    house. It was not in the original plans, but you do it anyway. A
    garage, back deck, room over the garage, family room, sun room,
    wrap around porch, tool shed, swimming pool, flower garden,
    vegetable garden, etc...

    Applications programs can dynamically load additional code, that
    were not there to begin with. Plugins, extensions, additional
    libraries. For example, Firefox may load a plugin or extension to
    run Flash, or Java. But until it downloads a page that needs
    those services it will not bother. But each of these plugins,
    extensions, libraries will require additional Virtual Memory
    address space, so the applications VM size will grow some more.

    Finally, some applications have memory leaks. Those of us in
    programming don't like to air our dirty laundry in public, but it
    does happen. In this case an application with a memory leak will dynamically allocate memory, and sometimes forget to free it for
    reuse. As time goes by it forgets more and more dynamica memory,
    and grows to a very large VM size. Quiting such an application
    will free up all the VM.

    Now having mentioned Memory Leaks, I am _NOT_ saying anything
    about Firefox. For the most part Firefox is just using more VM
    because over time it caches more web pages and images, you open
    more tabs, you eventually load a page with java on it, you
    eventually load a page with Flash, you get around to loading a
    page with Quicktime needs (video or audio), etc... and Firefox
    dynamically allocates more memory.

    OK, now if you have lots and lots of memory, then as your
    application uses the VM, real memory is allocated to it, and
    everything is great.

    But generally more real memory will be needed than physically
    exists, and the operating system will now start to page.

    First it will look for pages that are inactive. The OS keeps tabs
    on the usage of Real memory, and if an application loaded a
    section of code or data awhile ago, but has not used it recently,
    that memory will be marked inactive. Inactive pages of Real
    memory that are read-only and have original copies on disk (like
    application or library code), are easy cheap sources of additional
    memory, as the OS just needs to mark the VM map to say the
    application program needs to get this from disk if it needs it
    again, and then just give the memory to the task that is in need.

    This is one of the ways you will see an application program pagein
    data when you switch to it. It was idle while you were away,
    pages became inactive, eventually the inactive pages were needed
    for something else, so the read-only pages were released for other
    needs.

    Inactive memory that has been modified, need to be paged out
    before the memory can be used. Even if there is an original on
    disk, you do not use that as the modified values are not the
    original values, so space in the page files is allocated, and
    these pages are paged out. (if the page was paged out before,
    then it already has a space in the page file, and will just be
    paged back to that space).

    These paged out pages are also a source of pagein activity, when
    you switch to an app. The big difference is that you paid the
    price of paging it out and paging it in.

    Also when you start paging out, there is a very good likely hood
    that you may soon reach the point when you application is paging
    against itself. That is to say the application is so big and
    doing so much work on so much data, that it is not longer getting
    pages from other idle applications, it needs to get pages from
    itself. Of course the application doesn't know that, the OS makes
    decisions and if there is no other memory to free, it will start
    to take if from active page of the application itself. This is
    generally the case when you are seeing constant paging. It can
    also happen if you have several active applications running
    concurrently, like playing iTunes while doing software update,
    while surfing the web, while downloading email, while Photoshop
    runs a complex filter, while using iChat video session with your
    Mom, etc... Then everyone is stealing pages from everyone else.


    An excellent description Bob. You put it nicely into context for an OS X
    user too.

    I've only one thing to add, and that is what happens when you run out of
    the current pagefile space.

    At boot time, OS X allocates 64 MB of pagefile space. If you have oodles
    of RAM this may be sufficient until your next boot (where oodles varies
    with the applications you run and size of files you may be reading into memory).

    When the first pagefile is full, OS X allocates another 64 MB pagefile,
    and now has a total of 128 MB of pagefile space to work with. The
    algorithm used for extra pagefiles is to double the total pagefile space
    each time an extra one is required.

    Please note that this algorithm may well be subject to change in future versions of OS X.

    By way of example on my iBook with 640 MB of RAM (the maximum for this
    model), I rebooted at 00:57 on Saturday morning, and this is what my
    pagefiles show:

    64M 8 Apr 00:57 /private/var/vm/swapfile0
    64M 8 Apr 02:46 /private/var/vm/swapfile1
    128M 8 Apr 04:43 /private/var/vm/swapfile2
    256M 8 Apr 09:28 /private/var/vm/swapfile3

    Note the differing creation times of the above files.

    Now, I have just fired up GarageBand, and an extra pagefile was created,
    so now we see:

    64M 8 Apr 00:57 /private/var/vm/swapfile0
    64M 8 Apr 02:46 /private/var/vm/swapfile1
    128M 8 Apr 04:43 /private/var/vm/swapfile2
    256M 8 Apr 09:28 /private/var/vm/swapfile3
    512M 9 Apr 21:58 /private/var/vm/swapfile4

    The only other thing to add is that once a pagefile is created, it stays
    until the next reboot. Before I upgraded to Panther and at the same time
    maxed out my RAM, I would sometimes see a couple of GB pagefile being
    used, and my system would become noticeably slower as a result. This may
    have been due to excessive pagefile fragmentation, as I was then running
    with little spare disk space, but I honestly don't know.
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Paul Sture@paul.sture.nospam@hispeed.ch to comp.sys.mac.system on Sunday, April 09, 2006 22:25:16
    From Newsgroup: comp.sys.mac.system

    Hans Aberg wrote:
    In article <5ae8c$44391fcc$5448a851$20117@news.hispeed.ch>, Claude-Albert Berseth <void@nospam.com> wrote:


    When executing the command vm_stat, here is what I get (3 first lines) :

    Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 70%)


    Thanks. I should perhaps have run 'vm_stat' before asking, but know
    everyone knows, which is good. :-)


    Hans,

    'vm_stat' on its own (no time parameter) shows this on the first line:

    Mach Virtual Memory Statistics: (page size of 4096 bytes)
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From dempson@dempson@actrix.gen.nz (David Empson) to comp.sys.mac.system on Monday, April 10, 2006 21:03:18
    From Newsgroup: comp.sys.mac.system

    Paul Sture <paul.sture.nospam@hispeed.ch> wrote:

    At boot time, OS X allocates 64 MB of pagefile space. If you have oodles
    of RAM this may be sufficient until your next boot (where oodles varies
    with the applications you run and size of files you may be reading into memory).

    When the first pagefile is full, OS X allocates another 64 MB pagefile,
    and now has a total of 128 MB of pagefile space to work with. The
    algorithm used for extra pagefiles is to double the total pagefile space
    each time an extra one is required.

    Please note that this algorithm may well be subject to change in future versions of OS X.

    They used a slightly different algorithm in early versions of Mac OS X.
    I forget exactly where the change occurred, but my recollection is that
    Jaguar (10.2) and earlier used a simple fixed allocation size for each swapfile, which was about 80 MB.

    The only other thing to add is that once a pagefile is created, it stays until the next reboot.

    Not always. I've found that if you do something like log out, and your
    virtual memory allocation happens to be just right, the system can
    usually delete the highest numbered (and largest) swapfiles. Quitting a
    lot of applications may be sufficient in some cases, but logging out
    ensures that nearly everything you run normally has quit (including
    Finder and the Dock, plus background things like WindowServer, which may
    have recently allocated memory.

    I was also aware of this "automatic deletion where possible" in Panther
    (10.3), but not sure about Jaguar (10.2). It definitely didn't get rid
    of excess swapfiles in 10.0 or 10.1 unless you restarted.

    --
    David Empson
    dempson@actrix.gen.nz
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Paul Sture@paul.sture.nospam@hispeed.ch to comp.sys.mac.system on Monday, April 10, 2006 11:55:11
    From Newsgroup: comp.sys.mac.system

    David Empson wrote:
    Paul Sture <paul.sture.nospam@hispeed.ch> wrote:


    The only other thing to add is that once a pagefile is created, it stays >>until the next reboot.


    Not always. I've found that if you do something like log out, and your virtual memory allocation happens to be just right, the system can
    usually delete the highest numbered (and largest) swapfiles. Quitting a
    lot of applications may be sufficient in some cases, but logging out
    ensures that nearly everything you run normally has quit (including
    Finder and the Dock, plus background things like WindowServer, which may
    have recently allocated memory.


    In my experience, quitting everything in sight hasn't deleted any of the swapfiles Of couorse it might have done when I wasn't looking, just not
    when I _was_ looking. :-)

    However, I've just logged out and in again, and the system had deleted swapfile3 (256 MB) and swapfile4 (512 MB).

    The fact that it didn't purge them back further indicates that swapfile2
    was still in use.

    I was also aware of this "automatic deletion where possible" in Panther (10.3), but not sure about Jaguar (10.2). It definitely didn't get rid
    of excess swapfiles in 10.0 or 10.1 unless you restarted.


    I am running Panther. I too am not sure about Jaguar, but tend to think
    that the automatic deletion feature wasn't there.
    --- Synchronet 3.18b-Win32 NewsLink 1.113