MacOS X dont support VM (VIRTUAL MEMORY).. Since its running on Unix system... No reason for us to use VM.. Let Unix handle the memory.. I know there is cache and allow us to adjust it but how? Beats me.
Basically to disable dynamic_pager you need to comment out the line in the file /etc/rc
What I'll do is give you a patch file to do it for you,
it will setup the hostconfig file so that the dynamic pager is turned OFF by default, and you can enable it again but simply updating that flag.
The file attached is a Zip containing PATCH files, they need to be run from the command line.
Save the attachment (Patches.zip) out to your Desktop folder, and run the following from a Terminal Window:
This will make two new files rc.patch and hostconfig.patch
in the current directory.
Now run these:
sudo patch /etc/rc rc.patch
(enter your account password when requested for a passowrd)
This will add an "if" statement around the dynamic_pager section in the /etc/rc file.
then run the other patch as so:
sudo patch /etc/hostconfig hostconfig.patch
(again enter your passowrd if requested)
This adds a DYNAMICPAGER=-NO- line to /etc/hostconfig
which turns OFF the dynamic_pager on bootup. All you do to reenable it is edit /etc/hostconfig and change the NO to a YES on the DYNAMICPAGER line.
Let me know if your unsure about using these patches or have any problems.
It will probably not give you much of a performance difference unless you're running many programs each needed large gobs of virtual memory.
Now, to straighten the lies on VM a bit, under unix all memory both Physical and Disk based is terms "virtual memory" it exists in one big pool.
Here in lies the difference in terminology between OS-9's Real RAM plus "Virtual" (Disk based) Swap area, and OS-X's "Virtual Memory" system offering a mixture of disk and chip based ram.
Yes Unix VM support is way better than OS9's offerings, however, OS-X uses a "file" based disk paging setup, this means that as you need more virtual memory in the pool it creates an 80meg file on the disk to page things out to.
the creation of such a file can offer a performance hit.
Also, because you have disk updates happening all over the place, it is possible with dynamic paging, to cause excess fragmentation of the filesystem.
Most modern unix operating systems offer a partition based swap schema, where you designate a partition as "swap" and it does not form part of the filesystem, as it is a true reserved area of disk for using as disk-based virtual memory. This is ultimately faster and a cleaner approach to disk-paging. It's unfortunate as someone else on MacOSX.com pointed out, that Apple seem to have not given the Kernel and Libraries the nesecary ability to support mounting a "swap" disk in this manner.
Rather they have forced the use of the Dynamic_pager to auto create and shrink memory on demand.
So, on a busy machine with lots of drive trashing happening, dynamic paging to disk can be significantly slower than fixed disk paging systems. And as such some user like to turn it off, so they get NO disk based paging.
Ultimately this is probably a bad thing, since most Unix's and I assume OSX follows suite, page out unused processes to less priority marked area's. e.g Physical RAM is priority 0 disk is priority 1 so, if a process hasn't been used for a long period of time, then it is paged out to disk, where it can be called up upon request. But in the mean time you end up with more free physical memory in use. This is why it could be bad to disable your dynamic_pager.
Personally, I'd like to see fixed disk paging available, I'm much happier partitioning off say 1024meg of disk and knowing that my machine has 1024meg + 560 mb RAM available as "Total Virtual memory". However in the mean time, I've made a 1024 mb partition and I moved the dynamic_pager's swapfile to this mount point so that I know it's at least not helping to cause any fragmentation to the OSX filesystem. Unfortunately this 1 gig partition shares the same physical disk device, if I had two disk's I would move the "swap" area off to the least used (trashed) drive, so that file opening/saving tasks don't interrupt the paging drives accesses.
Couldn't you just assign a static amount of swap space? (that's really what it is) I come from a windows background and did this all the time and got noticable performance gains when swapping. So instead of dynamically assigning space, which is a performance hit, you just say you want a gig or so of swap space. This way the swap file remains constant, so you get the benefits of the swap file without the performance hit of dynamically allocating the space. I have not tried this yet on my system. I just got X yesterday.
(reformed windoz user)
Brand new G4 733Mhz with OS X
That's what I meant in "fixed disk paging". Static sized swap areas. But OS-X doesn't support that.
Oh what's more, I read that the mach_swapon function seems to support compression in the swap area.
read 'man swaptab' for more info.
This would explain why the VM reported by 'top' is somewhat incorrect. e.g. in a machine with 544Mb ram, and only one 80meg swapfile existing. I get upto like 1.5gigs of VM available. it's obviously compressing elements when paged.
This is such a stupid thing. I've got gigs of disk sitting here for use, and I'd love to
a) make a statically sized swap area.
b) have it NOT compressed so the CPU isn't working to compress/decompress all the process data.
What do the options for dynamic_pager mean? The default command has -H 40000000 -L 160000000 -S 80000000. I thin -S is the start swap file size. So would -h and -L be the limits? If they are couldn't you just put all three options to the same value and the virtual memory file would never grow or shrink? This would be essentially what I do under windows.
Originally posted by MacFreak MacOS X dont support VM (VIRTUAL MEMORY).. Since its running on Unix system... No reason for us to use VM.. Let Unix handle the memory.. I know there is cache and allow us to adjust it but how? Beats me.
I read somewhere on the forum about moving the VM swap file to another physical HD. How do you do this? This would be a good thing for me because I want to minimize HD fragmentation and have peak performance all the time. I have a 400MHz G3 with 384MB RAM (another 256MB is on the way), 12GB ATA-66, 18GB Ultra SCSI HD and probably won't be getting another computer until the G5 is out. If someone gives instructions, please give clear concise instructions for using the command line. Thank you.
The -L and -H options are not limits they are watermarks on when to purge or increase the swap space.
Basically if you hit your High watermark, it will create a second -S <SIZE>'ed file for swapping. if you hit it's low water mark after a period of time it will purge the file of any unused area and thus either remove a swapfile or shrink the primary one to contain what's needed.
However the options are a little confusing, given that the LOW mark needs to be higher than -H + -S settings added.
I think the idea is that the low mark come into effect mostly when additional swapfile have been made.
e.g. with settings (comma separated for reading)
-H 40,000,000 -L 160,000,000 -S 80,000,000
Means to start with 80meg file, if you hit 40meg usage, create another swapfile of 80meg as needed, and if you drop to only then using 160meg you can start cleaning things up.
Well that's how I figure it, but it's behavior is somewhat
unpredictable. And as I said the swap areas seem to be compressed, so it's hard to tell how the marks work at all.
Anyways, Moving the swapfile's is easy enough.
edit /etc/rc file and there is a like above the "dynamic_pager ....." line that is
I simply changed this to be swapdir=/Volumes/VM/pager
which means you need a disk called VM and it'll move it to that disk under the pager directory.
As for turning it off, in a previous post I said this is probably a "bad" idea. IF you put a Gig of ram in a box, you chances of it paging out anything are slim, unless you're really hammering the box. And again, it will start buy moving unused things out to disk first. e.g. if you run the Web server, but aren't using it, because your running the Classic environment with say Photoshop or something big, and doing lots of stuff, the Web server will get swapped out first, as will other untilised processes. This can only be a good thing
I have a G4-400 with 544MB ram, it performs admirably under OSX, only thing I'd like to increase at this point is CPU speed.
Thank you Dominion for responding to my post. I just wanted to move the swap file, not turn it off as another post wanted. I don't want to mess with turning VM off, I agree, that would be bad; just looking for increased system performance. Thank you again for the instructions.
Right now I am amazed how easily it was to get OS X running on my box...but it runs well, but a bit slow....
Right now I have my 4 Gig 7200RPM SCSI drive partitioned into 2-2 Gig partitions (one OS X one 9.1).
I do have a spare 1 Gig 5400RPM drive (origional one from my 7500) and was wondering if there would be any advantage for me to put the swap file on this drive all by itself.
So what do you think would be faster...the swapfile on a faster drive along with the OS...or all by itself on a slower (tested to be about half the speed of my 4 Gig in some tests a while ago) drive???
Thanks for the info
P.S. I know I should just buy a new Mac, but I don't have the $$$ and love to tinker around anyway.
I doubt you'll see any performance increase.. possibly even a slowdown do to slower speed spindles.
The troublesome thing is, that until you're really swapping hell out of the disks you wont really notice much difference. I've been running OSX for a few weeks now, and I'm still yet to see it use up all of the first 80meg swapfile.
your G3/300 is going to be your slowing factor, so long as you're meeting the memory requirements. This is the one annoying thing about Mac's.. to upgrade that G3 your almost going to have to replace the whole machine :-/ *whimper*
I wish they where just CPU up-gradable But at what cost...