Reviews and Daily News with a  Difference!
Select a Topic Area To See a List of Related Reviews & Articles
Systems  | CPU Upgrades  | SCSI | IDE | Firewire  | Video  | Audio  | Games  | Misc/OS  | Archives  | Search
7/26/01 Thursday's News: Story DetailReturn to News Page


OS X Swapfile Sizes and Reference Links:
Published: 7/26/2001
Last Update: 1:45PM

Swap Cop Swapfile Utility: I've not used it personally, but there's a freeware utility for moving/changing the swapfile location available at http://homepage.mac.com/jschrier/.
** Note ** as of version 1.1.2 it's not designed to work for OS X 10.2, but the author says you can request that by making a donation on his wishlist page.
(NOTE: This article is from July 2001 -The Info below referred to using 10.0.x., not the August 2002 Jaguar (10.2.x) version. See the updated Dedicated OS X Swapfile partion article for a reader's 10.2 swapfile partion mods.)

Yesterday I upgraded the drive in a G4 Cube and partitioned the drive into 3 volumes including a dedicated OS X swap file partition. I used the reader tip and download on this previous article here and it does seem to work. There was a swap file created on the partition, but the size was much smaller than I expected. (384MB RAM in the machine and the swap file appeared to be only 84MB.) At first I wondered if there was a swap file being created on that volume, but restarting in OS 9.1 allows you to see there is a one on the partition. I guess I'm just used to seeing other OS's use large swap files.

Update - Several readers replied to this post noting that OS X's swap file is allocated in appx 80MB sizes, so what I've noted above is normal apparently. Some of the replies below like developer Bill Chin's include reference links and more info on tweaks to the swap file.

Reader replies regarding the OS X swap file. (Latest reports first)

" By default, Mac OS X uses 80mb fixed sized swap files. It'll create additional swap files as needed. This is controlled by the /etc/rc script file which is run during boot. You can see the part near the end where calls dynamic_pager. By fiddling with the parameters, you can hose your machine. Or you can change the default sizes. I did this on a PowerBook (Wallstreet) with a very small hard drive to have a finer granularity. Using 40mb swap file size, when consuming 90mb of swap, only 120mb of disk space would be dedicated instead of 160mb. Not a big change, and not worth doing for most people. You could have it create a much larger file too.

Mac OS X can actually do swap object re-location and swap file removal. This actually is a pretty cool improvement from the ever expanding swap file problem under NEXTSTEP/OPENSTEP. For more details, you can refer to the Darwin source code, attend WWDC, or take a look the Virtual Memory section of my WWDC 2000 Kernel Session notes:
Of course, there's more information in Apple's Developer documentation:
..Bill Chin
M Dimension Technology "

" With 768MB and even with 512 and then 640MB I never saw more than the default on 80MB swap file.

If it needed more it would create multiple swap files (0-n). It always "maps" resident, virtual, page-fixed, purgeable etc. So that Classic is "allowed" 1GB but I don't think it would ever use it.

Using terminal "top" confirmed that there were not any pageouts even under heavy loads at the end of the day (3 web browsers: OmniWeb, IE, Fozilla), Classic (Quicken, Word 98, Excel 98, Acrobat 4), Mail, Eudora, Preview, Graphic Converter, TextEdit etc.

All but 10MB of RAM was used under heaviest load.

What I want to learn is how to enable the Memory File System (MFS) to enable virtual volumes to mount and load files and programs or to use for scratch.
Greg "

" Hi Mike,
My swap file size is now 0!

I noticed poor vm performance while building a large C/C++ project. In essence, it would exhaust available RAM (544MB on my machine - I ran "top" in a terminal and watched it disappear) even though the sum total used by processes never rose beyond around 70MB (I suspect the remainder of the used RAM was disk blocks being cached by the kernel). Once physical RAM was exhausted it would begin to swap out unused/defunct pages to disk.

To avoid this unnecessary paging I commented out the dynamic_pager line in /etc/rc, which effectively turns off virtual memory. Other users with large amounts of RAM may also want to do this.
Sacha "

" I haven't looked too closely at OS X's VM, but speaking generally:

MacOS 9 uses a very antiquated VM system that limits virtual memory to a fixed size and requires that space for the entire quantity (including RAM) be mapped to disk at the start.

Modern unix variants have much more flexible (and complex) virtual memory systems. They only take up disk space when there is data that doesn't fit in RAM. Thus the swap file should start out very small (8KB?) with just the index block, and grow only as needed.

OS X appears to follow this model, although I haven't seen yet if it will shrink the file.

A few years ago I wrote a brief primer on unix virtual memory:
It's still applicable, although some of the examples are a bit dated.
Seth "

" In response to the item posted on the homepage today, Darwin (and I assume BSD) uses VM in approx 80MB 'chunks'. At boot up the first chunk is created (called 'swapfile0'). Additional chunks are only created when needed. Unlike Mac OS 9, where the VM has to be as large as the RAM, Darwin only uses VM when it has run out of physical RAM. So if you have a lot of RAM, you will very rarely get more than one 80MB swapfile created.

The reason why many Linux 'swap' partitions are larger, is they have to be able to hold as much VM as needed. They cannot just create an extra file, so are made larger to prevent disk full errors.

On my G3 with 1GB RAM, I have never had more than one file, and looking at the modification dates in the terminal, it seems only to be accessed (created) at startup - and not again.
Hope that helps,
Roland "

" Fact is that MacOS X uses 80MB big swap files, and adds new swap files when needed. Right now I have 4 80MB swap files.
David "

" X allocates swap files in 80M blocks, thus until you need to go into swap, you will not see it using any space.

There are two philosophies regarding swap. One says that you should allocate everything into a contiguous dedicated volume to prevent fragmentation, and also so you know precisely how much swap space you have. This is how most UNIX implementations do it, because the extra work of partitioning is just not a big deal for a UNIX sysadmin.

The other holds that you should allocate on a main drive, so you do not need to decide at partition time how much swap you want. As you need more, grab another big chunk of space on the drive. If done poorly, you get fragmented swap files, but if done right, with the proper OS support, it can be quite effective. After all, it is fairly rare to need to cross a swap boundary anyway if the allocation units are large enough.
Scott "

" OSX creates Swap files about 84MB in size a s needed. I set up a swap partition by a different means and was surprised that 1GB was not really needed. Surprisingly it's rarely need to have a swap partition larger than 380-512MB.

MacOSX on it's own may be somewhat sloppy in not erasing those swap files when they are no longer needed but will reuse previous ones if needed. Usually you will find maybe 3 or four at most in private/ after heavy use.
-Josh L. "

" OS X uses an ~80 MB swap file size. However, is uses as many of these files as it needs. It will create more files as needed. I think you simply hadn't stressed the VM sufficiently, or you would have seen a slew of these 80MB files
Michael "
Return to Main News Page

Mini Dual HD!

(Ad/Sale items)

= UPGRADES by Mac =
Upgrades just for

= Used Macs =
(Click for List)

SSDs from under $50!
Fast SSDs for Most Macs/PCs

= ThunderBolt =
Drives & More

Up to 6 TB HDs!
Hitachi, WD, Seagate, Samsung HDs

= 2.5in HDs & SSDs =
Notebook Hard Drives and DIY drive/case kit bundles

Lifetime warranty RAM Upgrades!

Internal and External Superdrives/Blu-Ray drives

Graphics cards, TV tuners, DVR, adapters and more.

Apps, Utilities, OS, VM, Games and more

WiFi and Bluetooth Devices/Adapters/More

= Repair Service =
for iPhone, iPad, Macs

= iPad/iPhone/iPod =
Accessories, Cases, Repairs & More

NuGuard iPhone Case *Extreme* Drop Tested!

XLR8YourMac T-Shirts


Help Fight Hunger

= back to www.XLR8YOURMAC.com =

= Other Site Topic Areas =
Mac Mods/Upgrades | CPU Upgrades | Storage | Video | Audio/HT | Misc/Software | Search | Recent

Copyright © , 1997-2014. All Rights Reserved
All brand or product names mentioned are properties of their respective companies.

Legal: Site Privacy and terms/conditions of use.