Slashdot Mirror


Comprehensive Guide to the Windows Paging File

busfahrer writes "Adrian's Rojak Pot has a nice article about the internals of the Windows paging file. It explains what a paging file is and lists the differences between a swapfile and a paging file. But first and foremost, a large part of the article deals with the various methods of optimizing the Windows paging file, thus yielding a notable performance gain for people who are not overly blessed with RAM."

94 of 495 comments (clear)

  1. Defrag first, man. by inertia187 · · Score: 4, Informative

    One of the biggest performance helps is to keep the paging file from being fragmented, and I'm not talking about three or four fragments.

    I've come across workstations where the paging file is in thousands of fragments. This happens when someone messes with the settings. For instance, they might increase the size of the paging file thinking it'll help to have more. Normally, it's not a bad idea to increase it but if the drive is heavily fragmented, Windows dutifully uses the fragments for the new space.

    The only way to fix it is to completely delete (deactivate) the page file, then do a defrag, then re-create the page file (several reboots involved).

    That's probably the best way to tune the page file. There, I saved you from having to take the time to read the article.

    --
    A programmer is a machine for converting coffee into code.
    1. Re:Defrag first, man. by UCFFool · · Score: 5, Insightful

      OMG, you mean you didn't read the article and possibly learn something?

      Honestly, I wonder why people take the high and mighty road. The number one problem with computers is people simply don't understand them. The number one way to solve this problem is to educate the user about these little facets of the OS.

      The article covers some very basic differences in plain english, and unlike the 'just to do this and leave me alone' attitude, puts the user one step closer to a positive computer experience... a tough thing in today's virus/trojan/adware /. world.

      --
      "The more pity, that fools may not speak wisely what wise men do foolishly" - Touchstone,Shakespeare's "As You Like It"
    2. Re:Defrag first, man. by The+Snowman · · Score: 5, Interesting

      One of the biggest performance helps is to keep the paging file from being fragmented, and I'm not talking about three or four fragments.

      The best way to avoid fragmenting the swap file is a method I learned a long time ago, and the author mentions in his article but doesn't talk about much: keeping it on a separate partition. Sure, NTFS doesn't have a swap partition type like Linux does, but I keep a 2 gig partition with a fixed-size swap file on my WinXP box. Set the registry key to ignore "out of space" warnings for that drive, remove read privileges from everybody to that drive, and you basically have an invisible, un-fragmentable swap file that is invincible to user stupidity (I share my computer with my wife, so that last point is important. She does not have Administrator privileges on my box).

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    3. Re:Defrag first, man. by Monkelectric · · Score: 3, Insightful
      OMG, you mean you didn't read the article and possibly learn something?

      How could he? 15 posts and the server is toast.

      --

      Religion is a gateway psychosis. -- Dave Foley

    4. Re:Defrag first, man. by vp_development · · Score: 5, Funny
      ...She does not have Administrator privileges on my box...


      This seems unfair since I'm assuming you have admin privs on her box

    5. Re:Defrag first, man. by Clay+Pigeon+-TPF-VS- · · Score: 5, Funny

      What are you talking about?! Men never have admin privs on a woman's box.

      --
      Viral software licensing is not freedom, it is in fact GNU/Socialism.
    6. Re:Defrag first, man. by Anonymous Coward · · Score: 2, Funny

      Probably from low amounts of RAM, and slow fragmented swap file usage.

    7. Re:Defrag first, man. by dfn5 · · Score: 5, Funny
      What are you talking about?! Men never have admin privs on a woman's box.

      At least, not after marriage.

      --
      -- Thou hast strayed far from the path of the Avatar.
    8. Re:Defrag first, man. by blackmonday · · Score: 4, Funny

      Hey - That's better than her rights being set to "Everyone".

    9. Re:Defrag first, man. by the+unbeliever · · Score: 4, Funny

      Access to her box is on a per-request basis, most likely.

    10. Re:Defrag first, man. by The+Snowman · · Score: 4, Funny

      ...She does not have Administrator privileges on my box...

      This seems unfair since I'm assuming you have admin privs on her box

      No, I don't want admin privileges on her box. I don't want to have to deal with daily admin tasks. Instead, I am a power user. Oh yeeeeah!

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    11. Re:Defrag first, man. by riptide_dot · · Score: 2, Funny

      and you basically have an invisible, un-fragmentable swap file that is invincible to user stupidity (I share my computer with my wife, so that last point is important. She does not have Administrator privileges on my box).

      This seems unfair since I'm assuming you have admin privs on her box

      If she reads that last comment, I'm thinking those rights are gonna get revoked...:)

      --
      I was in the park the other day wondering why frisbees get bigger and bigger the closer they get - and then it hit me.
    12. Re:Defrag first, man. by Profane+MuthaFucka · · Score: 2, Funny

      I'll settle for 'read-only'.

      Signed, the neighborhood peeper.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    13. Re:Defrag first, man. by dzym · · Score: 5, Funny

      It's called "root" privileges. Thanks.

    14. Re:Defrag first, man. by jd142 · · Score: 2, Informative

      Article is toast, but if you want to defrag our pagefile.sys, go to sysinternals.com and get their pagedefrag program. This has increased boot times on older computers running w2k by as much as 30 seconds. It also defrags some of the other system files.

      Sysinternals does good work.

    15. Re:Defrag first, man. by Bloater · · Score: 4, Funny

      The real problem is where you get a nude sunbather, and they give you read-only access.

    16. Re:Defrag first, man. by The+Snowman · · Score: 2, Insightful

      I have gone back and forth between admin and non-admin a few times, more time without admin rights. Some programs have a tough time running, mainly because they want to access stuff they really shouldn't.

      I think the problem is the developer culture that built up around Windows, coupled with its changing ideas of how to separate code and data. With Windows XP we essentially have the core idea behind Unix: a /usr and /usr/local directory (Program Files), and a /home directory (Documents and Settings). However, I have several programs that insist on saving data in Program Files instead of my home directory. This could be as simple as using the %HOMEPATH% environment variable, or using one of several Win32 API calls that do the same thing. Unfortunately, developers get lazy, use Program Files, C:\, Windows, etc. to store data. The only exception should be daemons such as Apache and MySQL that do not "belong" to a user, sort of like "nobody" in Unix. And there you have /etc, instead of dot files in /home. Sigh. The way things are, and they way they should be...

      Anyway, the point is that this can make it very difficult to run certain programs without elevated permissions when you lock down the Program Files and Windows directories.

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    17. Re:Defrag first, man. by Malc · · Score: 2, Insightful

      Yes, it can be a lot of work running as non-admin. But there's a certainly feeling of secureness knowing that half the worms and trojans out there can't get very far without admin rights too.

    18. Re:Defrag first, man. by mph · · Score: 4, Funny
      This has increased boot times on older computers running w2k by as much as 30 seconds.
      That's great! My machine's been booting too fast, and I've been looking for a way to make it take a half minute longer.
    19. Re:Defrag first, man. by NanoGator · · Score: 3, Funny

      "What are you talking about?! Men never have admin privs on a woman's box."

      Pity this discussion is strictly academic for the contributers.

      --
      "Derp de derp."
    20. Re:Defrag first, man. by networkBoy · · Score: 2, Insightful

      I just want to know how a Windows swapfile vs linux swap partition bashing thread turned into abortion rights!
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    21. Re:Defrag first, man. by Darren+Winsper · · Score: 2, Insightful

      Microwaves do one thing: heat whatever's placed inside them (assuming it contains water). Cars do one thing: take you from A to B. TVs do one thing: Display an image from an input signal.

      Computers are general purpose devices. They can do many things. With flexibility comes complexity, there's only so much you can do to avoid that.

    22. Re:Defrag first, man. by mcrbids · · Score: 2, Interesting

      I think the problem is the developer culture that built up around Windows, coupled with its changing ideas of how to separate code and data.

      Man, I hear you! I've written software using the %HOMEDIR% variable, as you suggest, but the software I wrote is multi-user capable. Meaning, that multiple people might use it, and each user has their own set of data.

      This works well in the Win98 world, but on XP, if several people share a computer, and somebody logs off the O/S and logs back in as another user, all their data is "gone" since %HOMEDIR% has changed.

      We can't require the user accounts, since many of our customers are still using 98/ME.

      So now what?

      I haven't had the chance to investigate thoroughly, but I've heard that even when things are "locked down" on an XP box, you can still create directories off the root directory!

      If we kept the files there, in a subdir, it just might make everything work without the above problems. Anybody else care to comment?

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
  2. Windows paging File... by demonbug · · Score: 4, Funny

    Would Mr. File please pick up one of the white courtesy phones? Your OS needs to talk to you.

    1. Re:Windows paging File... by k4_pacific · · Score: 5, Funny

      Picks up red phone.
      Hello?
      Voice on phone: No, the white phone.
      picks up white phone.
      Hello?
      PA system: Would Mr. File please pick up one of the white courtesy phones?
      (shouting) I've got it!
      PA system: Thank you

      --
      Unknown host pong.
    2. Re:Windows paging File... by GMFTatsujin · · Score: 2, Funny

      I see you're trying to pick up the white phone! Would you like to:

      * Talk to somebody on the white phone?
      * Listen to somebody on the white phone?
      * Call somebody on the white phone?

  3. swap file vs. paging file by LordNimon · · Score: 3, Interesting

    I can't read the article now because it's slashdotted, but is there a difference between the swap file and the paging file in Linux? Does Linux even have a paging file?

    --
    And the men who hold high places must be the ones who start
    To mold a new reality... closer to the heart
    1. Re:swap file vs. paging file by DNS-and-BIND · · Score: 3, Interesting

      Solaris can use a swap partition or a swap file on disk. You can even add more swap space while Solaris is running using mkswap. Had to do that a few times...running Solaris does not mean that your developers know how to create scalable software...

      --
      Shutting down free speech with violence isn't fighting fascism. It IS fascism!
    2. Re:swap file vs. paging file by tijnbraun · · Score: 4, Informative

      As far as I know it doesn't...

      Here is some more info about paging and swapping under unix

      AFAIK a page is an group of memory addresses that are being changed/addressed at the same time.

      But I could be mistaken

    3. Re:swap file vs. paging file by TheFlyingGoat · · Score: 3, Insightful

      I'm not sure if Linux has a paging file, but I fail to see why the linux swapping can't be done preemptively as well. If a program loses focus, swap the memory used by it, but retain the active copy in RAM. If another program needs the RAM, release it. If the program comes back into focus, clear the swap copy. Seems like it would give the best of both worlds.

      Article Text:
      We have all been using the terms swapfile and paging file interchangeably. Even Microsoft invariably refers to the paging file as the swapfile and vice versa. However, the swapfile and paging file are two different entities. Although both are used to create virtual memory, there are subtle differences between the two.

      The main difference lies in their names. Swapfiles operate by swapping entire processes from system memory into the swapfile. This immediately frees up memory for other applications to use.

      In contrast, paging files function by moving "pages" of a program from system memory into the paging file. These pages are 4KB in size. The entire program does not get swapped wholesale into the paging file.

      While swapping occurs when there is heavy demand on the system memory, paging can occur preemptively. This means that the operating system can page out parts of a program when it is minimized or left idle for some time. The memory used by the paged-out portions are not immediately released for use by other applications. Instead, they are kept on standby.

      If the paged-out application is reactivated, it can instantly access the paged-out parts (which are still stored in system memory). But if another application requests for the memory space, then the system memory held by the paged-out data is released for its use. As you can see, this is really quite different from the way a swapfile works.

      --
      You have enemies? Good. That means you've stood up for something, sometime in your life. --Winston Churchill
    4. Re:swap file vs. paging file by Alioth · · Score: 5, Informative

      Well, since you've had four incorrect and or unhelpful responses so far, let me shed some light:

      Linux only has a paging file (it's still called swap space though). This can either be a hard drive partition, or a regular file.

      To make it as a regular file:

      dd if=/dev/zero of=some_file bs=1M count=however_big_you_need_it_in_megs

      Then:
      mkswap some_file

      Then:
      swapon some_file

      You don't need to reboot, and you can add/remove these files at will using swapon/swapoff and the normal filesystem tools.

      The 'swappiness' of Linux can also be tuned: since kernel 2.6.0 there has been a proc file /proc/sys/vm/swappiness. This can be set on a value from 0 (try to never swap) to 100 (agressively write out pages to disk). By default, it is set to 60. To change the swappiness, say, to 40:

      echo 40 >/proc/sys/vm/swappiness

      Most 2.6-based distros have some GUI tool that can tweak parameters like this (Fedora certainly does).

    5. Re:swap file vs. paging file by Matthaeus · · Score: 2, Insightful

      I'm not sure if Linux has a paging file, but I fail to see why the linux swapping can't be done preemptively as well. If a program loses focus, swap the memory used by it, but retain the active copy in RAM. If another program needs the RAM, release it. If the program comes back into focus, clear the swap copy. Seems like it would give the best of both worlds.

      If you're talking about losing focus in the window manager sense, it's not possible under linux without some very specific hacks:

      If the window manager ran in kernel space, then it would be possible. Running a window manager in kernel space also would provide a very handy way to bork your whole system with a poorly written gtk app. It would also break the security model of linux.

      Now, maybe if kernel hooks were added in so that parent processes could tag their children for paging, that might go somewhere. I don't know all that much about kernel internals yet, though.

      If you're talking about losing focus in the sense of going to sleep, there's no reason why it can' happen because init handles all that anyway.

    6. Re:swap file vs. paging file by ArsonSmith · · Score: 2, Informative

      same with Linux. You used to prefer using a swap partition to a file due to the file system code slowing down your swap operations if it were on a file but about 18+ months ago I remember seeing a patch go into the kernel that made this not true any more.

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
    7. Re:swap file vs. paging file by TiggertheMad · · Score: 4, Funny

      To change the swappiness, say, to 40:

      You sir, are the coolerist. It sweets up the language to add colorfulistic verbing and adverbly structures like the one you buildily made aboverness.

      Rockeringly on, dude!

      --

      HA! I just wasted some of your bandwidth with a frivolous sig!
    8. Re:swap file vs. paging file by gnuman99 · · Score: 2, Interesting
      I'm not sure if Linux has a paging file, but I fail to see why the linux swapping can't be done preemptively as well. If a program loses focus, swap the memory used by it, but retain the active copy in RAM.

      I don't think you have any idea how a Linux VM works. There is no "focus" because there is no windows. There are processes and how they are run depends on the scheduler.

      Memory management of Windows sucks. There is no question about it. If I don't have a gigabyte page file, I run out of memory (according to Windows) if I play GTA 3 for a while. The process uses only about 300M, but windows pops up crap about running out of memory. Memory manager says windows is using 500M for caching. WTF?

      This is not a troll, but Linux's memory management is vastly superior. Even if I run programs that can use up 80% of RAM and cause cache to shrink, the swap is still not extensively used.

    9. Re:swap file vs. paging file by Alioth · · Score: 2, Insightful

      Umm, the file is called /proc/sys/vm/swappiness; I didn't make it up.

    10. Re:swap file vs. paging file by bheading · · Score: 3, Informative

      I am not sure about the article's validity when it claims that swapfiles are distinct from paging files. There are other claims, such as the implication that Microsoft invented the term "virtual memory", that are also rather misleading.

      It's not a matter of swapping "pre-emptively". The whole business is invisible to the user space and the locking is essentially done by the kernel. The CPU hardware (ie the MMU) basically watches every single memory access when the CPU is in the appropriate mode (ie protected mode on an x86). It has a list of mappings of address spaces in it's own small internal page table.

      What happens is that every time you access a region of virtual memory (for example anywhere in user space), the MMU looks up the address in it's own list of pages. If the associated region is not mapped by the MMU, a page fault occurs which is essentially an interrupt which gets trapped by the operating system. The operating system checks to see if it has a mapping for that address.

      If it does, it checks to see if that mapping is either resident, or a block which has been paged out to disk (ie to the paging file). If it has been page out to disk, another block of memory gets paged out and the requested region is paged back in.

      The MMU's cache of pages gets cleared on most CPUs whenever there is a process context switch (but not a thread context switch), this is one of the big reasons why threads are less expensive than processes because the MMU's cache of pages has to be repopulated.

      The algorithm used to select which region of memory gets paged out is where the real trickery is. Obviously if you are low on memory and switch repeatedly between two busy proesses, you will be constantly thrashing those pages on and off the disk.

    11. Re:swap file vs. paging file by pkphilip · · Score: 2, Informative

      Yes, Linux can make use of a paging file. You can create a large file and use mkfs to create a swap partition on the file.

      You can then mount this file as a swap partition. You can make a fstab entry to mount this file at boot up as a swap partition.

      Please see this URL:
      http://enterprise.linux.com/article.pl?sid=05/03/0 2/2250257&tid=129&tid=42/

  4. well.. by Anonymous Coward · · Score: 4, Funny

    They might want to adjust the paging file on their web server a bit...

  5. Slashdotted already? by cmburns69 · · Score: 4, Funny

    Given the speed of the slashdotting, I'd say he needs to add more ram to his box, and stop relying on the paging file for speed...

    --
    Online Starcraft RPG? At
    Dietary fiber is like asynchronous IO-- Non-blocking!
  6. Let Windows manage the pagefile. by Anonymous Coward · · Score: 3, Informative

    People are going to argue this a lot, because geeks like to fiddle with things. Clearly, the thing isn't optimized until I have changed the settings !!oneoneone!!!

    But the best way to optimize the paging file in Win2000 (and later) is to leave it alone. Windows will manage the paging system just fine on its own.

    1. Re:Let Windows manage the pagefile. by MSFanBoi · · Score: 2, Insightful

      Not really true. On application servers, it's best to set a static pagefile. Heck on SQL boxes its sometimes best to not even have a pagefile... Letting Windows manage your pagefile decreases performance, as it leaves something else for the CPU to do and something else for the disks to do. Put a page file on another disk (or other partition if you don't have another disk). Make the pagefile 1.5x the amount of RAM you have (up to 4 GB anyways). I've found this works well and gives the best performance for most systems (with the exception of SQL and ORacle servers)

    2. Re:Let Windows manage the pagefile. by value_added · · Score: 2, Informative
      But the best way to optimize the paging file in Win2000 (and later) is to leave it alone.

      Sorry, but that's not good advice. There are real issues with fragmentation on NTFS file systems. You can create an empty NTFS partition copy a few files to it, and you can be sure that if the files are larger than 4KB, those files will be fragmented. And if they are of substantial size, the files can be split into dozens of pieces. Moreoever, Windows provide no native ability to defragment metadata on any partition.

      With respect to the swap file, Windows provides no native ability to defragment it. A default installation with default settings will have your swap file spread like diarrhea across the sytem partition. What is good advice is either to set the swap to a fixed min/fixed max, and/or invest in a defragment utitilty to replace the stripped down version of Diskkeeper that comes bundled as the default defragmenter. (Note that, when possible, replacing most most anything on any Windows box with better alternatives is *always* a good idea so leaving most anything to Windows to manage is generally a bad idea.)

      Among the commerical alternatives available, Diskeeper and PerfectDisk are excellent choices, and provide the ability to defragment files, metadata and the swap file.

      Also note that you will get noticeable performance boost if you mvoe the swap file is located on a separate drive (different IDE channel).

  7. FreeRAM by yuriismaster · · Score: 5, Informative

    http://www.bysoft.com/freeram.asp

    A free application that you can use to 'pre-page' out pages right before loading up your application. What it does is hog as much RAM as much as it can, forcing the OS to page out any unnessecary applications.

    I've seen the standard Explorer + lsass + cwrss + all the svchosts memory footprint go from 80-ish megs to 20. Running this before your game will allow quick load-times and quicker performance.

    1. Re:FreeRAM by finnhart · · Score: 4, Informative

      In the case of firefox, the application itself is responsible for getting out of RAM when minimized. I don't know what Mozilla you're running, but it may have the same behavior & fix.

      You can change the behavior by modifying the config.trim_on_minimize key (accessible via about:config). See http://windowssecrets.com/041202/) for more info on this.

      Makes a big difference - no more two second pauses when restoring firefox.

  8. not overly blessed with RAM by Tenebrious1 · · Score: 4, Funny

    ... for people who are not overly blessed with RAM.

    You mean those who's PHBs said the "minimum" requirements were good enough.

    --
    -- If god wanted me to have a sig, he'd have given me a sense of humor.
  9. Another patent attempt by IvanD · · Score: 2, Funny

    and It's called a paging file, because if they call it swap they couldn't get the patent!

    Or maybe the will be figthing trying to convince the world that they came up with the idea of a swap space!

  10. Windows' memory mismanagement woes by Entropius · · Score: 2, Insightful

    It seems like Windows' treatment of virtual memory is inefficient. Why use a file for swap -- incurring ntfs overhead and fragmentation -- when you could use a swap partition (like Linux) without exposing the user to any additional complexity (which is the usual tradeoff for efficiency gains).

    I had to upgrade my laptop from the stock 512 to 1.25GB just because WinXP thrashed the paging file so much. Granted, I multitask like a demon, but it shouldn't take 30 seconds to swap Firefox back in.

    1. Re:Windows' memory mismanagement woes by alta · · Score: 2, Insightful

      I think this is a fine idea for a server with competent sysadmins, but not so good for an end user...

      Say, a rule of thumb is, your page file is 2x the size of your physical memory. My mom takes her computer to best buy, and she goes from 128MB of memory to 512MB... typical situation. Now, her windows pagefile will grow accordingly. Or if I manage it for her, I would manually change it. But what if I had to tell her, "well now we have to remove everything on your computer to resize your paritions"?

      --
      Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
    2. Re:Windows' memory mismanagement woes by vadim_t · · Score: 2

      Except, why would you do that? If she could manage with 128MB, then there's no point in adding more swap when you get more RAM.

      This is something that happened to me on Linux. I found that on a computer with 1 GB RAM, anything more than 256-512MB of swap is almost certainly excessive. Why? Because with so much memory, you should never really be using much swap anyway. When you end using so much is when some program goes mad and decides to allocate all the available memory. And then you'll find that having a lot of swap is actually a bad thing, due to the time that takes to fill it.

      Having less swap can be a good thing, since it makes the system run out of memory and kill the offending program much faster.

    3. Re:Windows' memory mismanagement woes by timster · · Score: 2, Insightful

      I don't understand why you would need to increase the size of the page file when you had just increased the RAM.

      The size of the page file needs to be the amount of virtual memory you need available minus the amount of physical RAM. So when you increase the RAM, it's appropriate to decrease the size of the page file, unless you are simultaneously planning on using more total virtual memory.

      In the Ancient Times, there were systems where the total virtual memory size was equal to the size of the page file. These systems were wasteful of page file space, so the rule of thumb that a pagefile should be twice the RAM was invented.

      In modern days, the old rule is usually not so bad, since systems with a lot of physical RAM tend to have that because a large VM footprint was expected on the system (else why buy so much RAM)? However, as RAM becomes cheaper, I think it is getting a little out of hand (at least for conventional desktop systems). A little bit of a page file is still good, because you will always have allocated VM that is not used for hours or days on end, but a home computer with 512MB of RAM doesn't usually need a gig of page space.

      This is why the Linux system makes a lot of sense. Unless the intended purpose of a machine changes dramatically, or physical RAM is removed, it's usually possible to come up with a good idea of the total amount of paging space needed at install time. If the machine starts running out of VM it is usually better to add RAM than to add swap, anyway.

      --
      I have seen the future, and it is inconvenient.
  11. The other Python by Mercano · · Score: 2, Funny

    thus yielding a notable performance gain for people who are not overly blessed with RAM.

    She has money, she has a title, she has huge... tracts of RAM!

    --
    #include <signature.h>
  12. WTF by OverlordQ · · Score: 4, Funny

    It's 44 Pages!! I mean heck, the average /. doesn't read one page news stories, but a 44 Page Article!? Not in this lifetime.

    --
    Your hair look like poop, Bob! - Wanker.
    1. Re:WTF by halivar · · Score: 5, Funny

      Frankly, I'm impressed you even clicked on the link.

  13. details of the windows paging file? by LMCBoy · · Score: 3, Funny

    c'mon, who gives a fsck?

    --
    Liberal (adj.): Free from bigotry; open to progress; tolerant of others.
  14. Before the defrag by Tumbleweed · · Score: 2, Interesting

    Make sure it's a fixed-size page file, not system-managed.

    By using 'Diskeeper,' you can also do some additional optimizations besides just defragging it; it's a nice app, though its warnings are overly-dire, and it insists of having something staying in memory all the time, which is irritating.

    1. Re:Before the defrag by Henk+Poley · · Score: 4, Informative

      I've mentioned it elsewhere already. But try PageDefrag and Buzzsaw.

      The first one will defragment your Windows pagefile on each boot. And Buzzsaw will defragment recently accessed files in the background, much less intrusive than Diskkeeper. Both are freeware tools.

  15. Printer Friendly link by Anonymous Coward · · Score: 2, Funny

    For God's sake, put a Printer Friendly link on your site so I can print the whole article. Having to read lots of text on my 14" EGA monitor makes my head asplode!

  16. One of the first paragraphs made me stop reading. by bigtallmofo · · Score: 4, Informative

    The site is so slashdotted that it took forever to load the first page which basically has nothing but useless history of swap files on it. Even the mirrordot doesn't appear to be working. Anyway, one sentence on that first page made me no longer interested in reading the article:

    Whenever the operating system has enough memory, it doesn't usually use virtual memory.

    This flies in the face of real world experience. You can have 4 gigs of RAM and nothing but Windows 2000 running and your OS will still use the swap file frequently. Don't believe me? Run Performance Monitor and monitor Memory, Pages/Sec and just click on a few things and you'll see that I'm correct.

    --
    I'm a big tall mofo.
  17. Does he really believe this? by Peaker · · Score: 4, Insightful

    The solution they came up with was to use some space on the hard disk as extra RAM. Although the hard disk is much slower than RAM, it is also much cheaper and users always have a lot more hard disk space than RAM. So, Windows was designed to create this pseudo-RAM or in Microsoft's terms - Virtual Memory, to make up for the shortfall in RAM when running memory-intensive programs.

    Amazing how they manage to turn everything around as though Microsoft invented the world of computing...

    Virtual memory, the term and the implementation have been around long before Microsoft came into existence.

    1. Re:Does he really believe this? by Valdrax · · Score: 2, Informative
      (Okay, I know that with the name MSFanBoi you have to be trolling, but I have to respond. I have no choice. Really. It's like some sort of Manchurian candidate directive or something.)

      Where does it say MS invented this?
      The solution they came up with was to use some space on the hard disk as extra RAM. Although the hard disk is much slower than RAM, it is also much cheaper and users always have a lot more hard disk space than RAM. So, Windows was designed to create this pseudo-RAM or in Microsoft's terms - Virtual Memory, to make up for the shortfall in RAM when running memory-intensive programs."
      It's implied in the phrase "they came up with" and in saying that the term Virtual Memory is one of "Microsoft's terms." They didn't come up with it. It was a concept widely used in computing since 1959. Everything used virtual memory by the time MS included it in Windows 95 -- even the Macintosh. The concept and the word are ancient, but the article presents it like it's some sort of wonderful innovation invented and named by geniuses at Microsoft.

      It's the kind of statements only an MS fanboy or someone else equally uninformed about the history of computing could make.
      --
      If it's for-profit but free, you're not the customer -- you're the product (e.g., the Slashdot Beta's "audience").
    2. Re:Does he really believe this? by pchan- · · Score: 4, Informative

      In fact, what he is describing is NOT virtual memory, but demand paging. At this point, I stopped reading the article.

      Virtual memory is the mapping of physical memory pages to a "virtual" memory address using hardware translation tables. This is done so that every application lives in its own private memory space, and cannot interfere with other applications' memory (or the OS's). Basically, this technique of memory isolation keeps user apps from crashing the system or other applications. Virtual memory support has been added to x86 with the release of the 80386 processors and 32-bit flat memory addressing. Of course, virtual memory has been available for years before this on such OS's as DEC's VMS (the Virtual Memory System), IBM's MVS, UNIX, and a bunch of other systems I'm too young to know about.

      The misnaming of demand paging was actually started by Apple (continuing their tradition of calling the box a "CPU") for their swap file management (long before MacOS's support for VM in OSX).

    3. Re:Does he really believe this? by Peaker · · Score: 2, Interesting

      Virtual memory is indeed the virtual tables that allow for virtual memory -> physical memory mappings that can differ for isolation purposes.

      However, those same virtual tables are used to mark pages as not-present to indicate they are stored on some external storage or do not exist at all. This is also known as a "Virtual memory" feature, so it is not inaccurate to say one of the purposes of virtual memory is to virtualize more memory than is physically available.

      Also, the 80286 already added the protection features required to prevent applications from crashing the system and each other, but those features are very complicated and although still supported, they are mostly unused by most modern operating systems.

      P.S Some of those features could actually be of benefit (for example, using segmentation to have the stack mapped only in the data selectors and not mappable in the code selector could prevent most b.o exploits)

  18. MSFT Patents Virtual Memory by Anonymous Coward · · Score: 2, Insightful

    To read the start of the article, you'd think there were no non Microsoft operating systems when DOS came out and that Microsoft invented the concept of Virtual Memory.

    I couldn't read any more after that.

    -Disgusted AC in PA

  19. Another interesting one re: XP and page file by TeddyR · · Score: 2, Informative
    --

    --
    Time is on my side
  20. CAUTION: Ignorant Article Writer detected by DrZiplok · · Score: 5, Informative

    There's a good reason why people don't write about VM systems often; the combination of writing skill and the ability to understand modern VM is extremely rare.

    Take most, if not all, of what the article discusses with a large grain of salt. Everything, from his history (did Microsoft invent demand paging? Hardly) to his terminology is flawed.

    Just reading the first 40 comments or so here reveals that VM remains one of those "black magic" areas, where reason is overcome by superstition and people will assert the most ridiculous, irrational and unsupportable things. Regrettably, the contents of this article do nothing to improve the situation.

    = Mike

    1. Re:CAUTION: Ignorant Article Writer detected by real_smiff · · Score: 2, Insightful
      i know next to nothing about VM systems, and even *i* can tell we have problems, by this sentence:

      Even the fastest hard disk is currently over 70X slower than the dual-channel PC2700 DDR memory common in many computers. Let's not even start comparing the hard disk with faster RAM solutions like PC3200 DDR memory or...

      riiight. excuse me while i laugh and read something else.

      --

      This is my Sig, this is my Gun. One is for Slashdot and one is for Fun.

  21. What if I am blessed with RAM? by supmylO · · Score: 2, Interesting

    I have over a gig of RAM but my laptop's HD is rather slow. How do I make it so that my computer will not use one of these files? I doubt there are many times when I am using all of my RAM, so I'd want to keep the HD use as little as possible.

  22. Virtual Memory by MCZapf · · Score: 2, Interesting

    The article is a little misleading. Virtual memory is not just space on a hard disk that you use when you run out of physical memory. Virtual memory is the practice of giving each process its own virtual address space that is independant of the physical address space. Doing this allows the OS to send some pages of memory to disk if it needs to, but the OS is still using the mechanism of virtual memory even if there is no hard drive at all. Each process's memory space is independant of the others'.

  23. Re:Or by XorNand · · Score: 5, Informative

    SysInternals (who make some of the best freeware available for Windows) has PageDefrag. It defrags your registry hives and pagefile at boot, before Windows loads. Very slick program and free to boot.

    --
    Entrepreneur : (noun), French for "unemployed"
  24. Re:One of the first paragraphs made me stop readin by RatBastard · · Score: 3, Interesting

    Turn off virtual memory and see how many MS apps suddenly stop working at all. And we're not talking memory pigs, either. Some screen savers don't run without virtual memory running, no matter how much RAM you have. It's really stupid.

    --
    Boobies never hurt anyone. - Sherry Glaser.
  25. Re:One of the first paragraphs made me stop readin by gid · · Score: 2, Interesting

    I've run into similar problems. I have 1 gig of ram on my machine, if I have my java ide loaded up, and run a game or something like UT2k4, and play for a bit, when I exit out, my machine will thrash like made. But then I tried just disabling the page file altogether because of someone's suggestion, and ya know what? Everything works fine, no memory problems, no thrashing.

  26. Re:Faster/easier method by mosschops · · Score: 2, Informative

    Use the free PageDefrag utility from http://sysinternals.com.

  27. pagefile vs. swapfile by Henk+Poley · · Score: 3, Informative

    It explains what a paging file is and lists the differences between a swapfile and a paging file.

    There is no difference.. He says that swapfiles would swap whole processes. I beg you pardon? Working on whole processes hasn't been the case since 'multiprogramming' on third generation computers (around 1965-1980).

    btw, a good program to defrag your Windows page file is PageDefrag

    Together with Dirms & Buzzsaw, you can keep your disk defragmented for free. Especially Buzzsaw is nice since it will defragment recently accessed files in the background.

  28. article still doesn't address misconceptions by Anonymous Coward · · Score: 5, Informative

    Well, they tried, but I think they really missed some very commonly-held misconceptions.

    I've just finished a project involving reconstructing process images from physical memory, including pages from swap, if available, so I've got a pretty good understanding of this stuff at a very low level.

    Misconception 1: Swap-file usage = performance degradation

    Yes, it is slower (usually by 3 orders of magnitude, not 1) to access a page (frequently 4K) from disk instead of memory. HOWEVER, effiency dictates that all available RAM be utilized as soon as possible.

    For example, in addition to running processes, we also use volatile memory storage to cache file data. Clearly, we want to cache as much as possible. Page replacement policies then become important to determine how much swap space to use. But usually it is much greater than 0, because we've got process image pages that are less frequently used than a lot of file cache pages. So we've gotta remember that data, but we don't wanna waste fast RAM on it.

    In other words, isn't it great that we can swap out pages from an unused process to make room for frequently accessed file data? Regardless of how much memory we have, that's a Good Thing.

    Misconception 2: Virtual memory = disk space

    Virtual memory is a mechanism for translating program-visible addresses to arbitrary storage locations transparently. This doesn't necessarily mean that disk space is used for swapping memory, it means, for example, that 5 processes can simultaneously be accessing address 0x5000, but the actual storage location is different for each. If the system (usually the page address translation facility on the CPU) determines that this address isn't at some location in volatile storage, it will bring in that memory from swap space and possible page out some other data. This is what the article is generally talking about.

    I've seen some other questions about pages. There are a couple reasons for treating memory in page-size chunks, where a page is usually in the 1-8k range (4k for x86). First, the page address translation stuff needs to keep data on translations. It must do this in > 1 byte chunks, since keeping translation data on every byte would require way too much storage. Disk I/O and other I/O is frequently done on page-by-page basis for that reason as well as for the sake of performance.

    Well, I rambled enough. Just wanted to clear a couple things up.

  29. Another link to article by SailFly · · Score: 4, Informative

    I found this link to the article: Swapfile_Optimization

  30. Re:Rojak Pot? by SteelX · · Score: 2, Informative

    Rojak is a type of salad eaten in Malaysia and Singapore. The term "rojak" is also casually used in those countries to mean "a mixture of everything."

    The term Rojak Pot, I assume, is meant to portray that this website talks about a wide range of topics.

  31. Very poor article by k8to · · Score: 2, Informative

    It spends a lot of time discussing what really happens in various situations and asserting that some theories that have been promoted are maybe incorrect, but does no investigative research.

    Moreover, all these performance claims are bandied about, and yet I see no benchmarking.

    Try harder, windows folks.

    --
    -josh
  32. Windows [2k, xp] virtual memory is not very smart by greendoggg · · Score: 2, Interesting

    I don't usually set out to bash windows, but the windows virtual memory subsystem is as dumb as a brick.

    At work I am blessed to have 1GB of ram, so I don't ever need to use any virtual memory. What I find really interesting is that windows is noticably more responsive when I turn off virtual memory entirely. Even though I'm never running out of memory, windows was always swapping things out that I needed soon when I had virtual memory enabled. And I'm talking about when I had 2/3 of my memory unused still (at least by applications, the disk cache could have potentially been using the rest). Just turning off virtual memory altogether made things much much more responsive/faster for me.

  33. 44 pages long, full of "sponsored links" by snorklewacker · · Score: 4, Insightful

    Putting http://text.burstnet.com/* into adblock makes for a slightly less annoying experience, but there's also the fact that it's 44 freaking pages long. Probably getting paid by the site hit or something.

    Do yourself a favor, give this content-lite article a miss. Make a small partition with ntfsresize, put a fixed pagefile on that partition alone. Works on every single version of windows and it's zero maintenance. Tah-dah.

    --
    I am no longer wasting my time with slashdot
  34. Help suppor the website! by alexandreracine · · Score: 2, Funny
    Help Support ARP!
    If you like this site and/or this article, please help support us by clicking on the IntelliTXT ads or any of the banners. Thanks!
    We sure helped them by /.ting the website :)
    --
    No sig for now.
  35. MS invented everything by couch_warrior · · Score: 5, Interesting

    It is always amusing to me to read how M$ "invented" technologies that were in common use by other operating systems while Bill Gates was still wearing diapers. Both paging and swapping were used on IBM mainframes dating back to the mid 1960's. What windoze (and linux for that matter) could REALLY use is the ability to deterministically dedicate portions of system resources to particular processes.
    Back when a 1 MIP, 1MB machine cost $1M, operators became highly skilled at managing workloads. Today everyone just throws oodles of RAM and disk at servers and lets the chips fall where they may , so to speak. It wouldn't be a bad idea to actually put a little thought into matching workloads with machine resources, and pro-actively matching them up by deliberate choice(For example - our company is running a prime-time ad at 9pm that features our URL, maybe that's a good time to shut down the normal file backup that happens then). Chaos theory is not always a good load balancer. But what am I saying, that's as outrageous as asking kids to put their money in the bank instead of buying video games...

    --
    "Sic Semper Path of Least Resistance"
  36. Re:linux swap by wolvie_cobain · · Score: 2, Informative

    maximium 128MB swaps on linux are an old myth.. from the mkswap man page:

    Linux knows about two styles of swap areas, old style and new style. The last 10 bytes of the first page of the swap area distinguishes them: old style has `SWAP_SPACE'new style has `SWAPSPACE2' as signature.

    In the old style, the rest of this first page was a bit map, with a 1 bit for each usable page of the swap area. Since the first page holds this bit map, the first bit is 0. Also, the last 10 bytes hold the signature. So, if the page size is S, an old style swap area can describe at most 8*(S-10)-1 pages used for swapping. With S=4096 (as on i386), the useful area is at most 133890048 bytes (almost 128 MiB), and the rest is wasted. On an alpha and sparc64, with S=8192, the useful area is at most 535560992 bytes (almost 512 MiB).

    The old setup wastes most of this bitmap page, because zero bits denote bad blocks or blocks past the end of the swap space, and a simple integer suffices to indicate the size of the swap space, while the bad blocks, if any, can simply be listed. Nobody wants to use a swap space with hundreds of bad blocks. (I would not even use a swap space with 1 bad block.) In the new style swap area this is precisely what is done. The maximum useful size of a swap area now depends on the architecture. It is roughly 2GiB on i386, PPC, m68k, ARM, 1GiB on sparc, 512MiB on mips, 128GiB on alpha and 3TiB on sparc64.


    so.. this is it..

  37. Re:Nice article, but ... by gewalker · · Score: 3, Insightful

    Dude, ever heard of VM/370

    or maybe Multics

    or, more obscure but even earlier Atlas

  38. Re:corrupt by tomhudson · · Score: 4, Informative
    It seems like Linux needs a paging file instead of swap partitions to become more responsive and more ready for the desktop.
    Don't bother - the article is full of inaccuracies.

    For example, even under Windows 3.1, the swap file only swapped in chunks of 4/8k. It's just that, on machines that were memory-poor (like we all were way back when), most users had their boxes configured with a 3/1 ratio of swap to real ram, and most of their free real ram then ended up being used to manage the swap file. 2/1 was the sweet spot.

    The DOS Shell program, on the other hand, worked by swapping out whole processes, allowing DOS 5.0 and up to appear to multitask.

    Pick up a copy of any decent assembler manual for the 2/386 from the early '90s, look for the instructions for swapping pages into ram. It's a hardware function. On a page fault, the cpu then goes through a look-aside buffer (8k worth of pointers each, IIRC, local and global), and then you can map pages of ram in/out as required. Just don't triple-fault, as the cpu would then go out of "enhanced" mode and/or reboot.

    Must be a REALLY SLOW day for this to be "news".

  39. Re:Or by egoots · · Score: 2, Informative

    I had run the Windows 2000 default defragger quite often before this, and most of the actual files were defragmented just fine, but there was tons of green slivers in the display there before I ran Diskeeper, and only a few chunks of solid green afterwards. I got rid of diskeeper because I didn't like it running in the background all the time, but its reboot defrag process was pretty good.

    The Windows 2000/XP defragmentor is a limited version of the Diskeeper defragmentor that MS licensed. By definition the limited version does not defrag the MFT or Registry hives. Also, you don't have to run Diskeeper in the background. There is a configuration setting for this! Just run it when you want to defrag

  40. Who needs a page file by GAATTC · · Score: 4, Funny

    Who needs a page file when you have a 10.00 GHz AMD Athlon, a 2000 MB DIMM, and a 30000 GB IDE Hard Disk http://www.amazon.com/exec/obidos/tg/detail/-/B000 22ACYK I quote from a review: "I was a little skeptical at first on how this thing would perform. However, when I installed and run the Seti@home program it started instantly finding alien signals, which where corrected, cleaned up and translated. I am now listening and talking to the supreme galactic defense minister about Earths surrender. Apparently this computer is not only tapping into the sun for power but also into the mysterious dark energy and tearing the universe apart. Just comes to show how bugs always show up in technology when you least expect it."

  41. Re:One of the first paragraphs made me stop readin by Foolhardy · · Score: 3, Informative
    In Windows, shared memory is done the same way that memory mapped files are. If you just want to share memory without mapping a file, you have to map a section of the page file. If there is no page file, this doesn't work. From CreateFileMapping:
    If hFile is INVALID_HANDLE_VALUE, the calling process must also specify a mapping object size in the dwMaximumSizeHigh and dwMaximumSizeLow parameters. In this case, CreateFileMapping creates a file mapping object of the specified size backed by the operating-system paging file rather than by a named file in the file system.
    Here's an example of creating shared memory between two processes using this method.

    I don't know why screen savers would stop working, but I bet the developers never planned for the creation of shared memory failing.
  42. The author fundamentally doesn't understand... by bartash · · Score: 2, Informative

    Larry Osterman writes in his blog that the author fundamentally doesn't understand what he's writing about. Mr. Osterman has worked at Microsoft for 20 years. How old is the author of the article?

    --
    Read Epic the first RPG novel.
  43. ...just to confuse things a bit more by abrax5 · · Score: 3, Informative
    You could use SwapFS from: http://www.acc.umu.se/~bosse/

    Then you can put your windows pagefile into linux swap partitions. :-)

  44. UNIX had no virtual memory until late 1980s by dananderson · · Score: 2, Interesting

    System V UNIX had no virtual memory until the late 1980s. Sure, there were specialized versions, such as BSD with VM added on, but it wasn't in stock UNIX. It was around though, and was in IBM 360 and Multics (1960s).

  45. disable the page file by jilles · · Score: 2, Interesting

    If you do have the memory, disabling the page file is the best thing you can do performance wise. In theory this is a bad idea, in practice it works very well.

    I have 1GB of memory. This is more than adequate for browsing, games, development, photoshop etc. So, two years ago I disabled the page file after discovering that with 300MB in use, windows was still swapping like crazy (and yes I had all the popular registry hacks applied which should prevent that). So eventually I disabled the page file. The immediate result of doing this is that applications become much more responsive. Suddenly multitasking becomes easy and fast.

    Normally when you work with an application for a while, all other applications get swapped to disk. It doesn't matter that you have 700MB of unused, readily available ram. So when you try to alt tab to them, windows spends a couple of seconds moving stuff back into memory. This is very annoying and totally unnecessary. The problem only becomes worse if you start to run some memory intensive programs because windows will swap aggressively then.

    Disabling the page file fixes this problem. The only disadvantage of doing this is that when you need more than 1GB it isn't there. This is typically the point where things would get very slow anyway due to swapping. In any case, this doesn't happen very often and is easily resolved by closing some applications. All games are optimized to run well with 256-512 MB. Most games don't use more than that, even if it is available. Office applications and other desktop software rarely use more than 100MB. Photoshop can push the limits but unless you are doing some extreme high resolution photography stuff with it, you will not run into any problems with 1GB. It's actually quite hard to run out of memory. Most things that are infamous for memory usage like ms flight simulator, doom 3, photoshop, vmware, etc all run without problems and without swapping.

    If you think about it, swapping is a really lousy solution unless you expect to run out of memory. Disk is many times slower than ram. The reason that you open programs is that you want them ready for action. Swapping them to disk is therefore undesirable. The only reason it would be desirable is if the total amount of memory used by all of your running programs is larger than the amount of memory you have. So if you have 256 MB, swap files are a nice poormans solution to the problem that you don't have enough memory. If you have 1GB you shouldn't have that problem (and if you do, buy another GB).

    --

    Jilles
    1. Re:disable the page file by pe1chl · · Score: 2, Interesting

      If you think about it, swapping is a really lousy solution unless you expect to run out of memory. Disk is many times slower than ram. The reason that you open programs is that you want them ready for action. Swapping them to disk is therefore undesirable.

      This is your situation, your opinion, and the base of your success.
      Other may have different situations and swapping may be better for them. On my Linux box I typically have 160-200 processes running, and I don't need them to be all ready for action. There is only a subset that needs to be ready for action, and I want those to be in RAM, together with the cached disk data that they access.
      Other programs, that are waiting for something that is unlikely to happen or are sleeping for some time (e.g. to check for OS updates once a day) I don't need to have in RAM.

      It has been shown many times that having some swapspace is better for performance in typical systems. Maybe not in your system.

  46. Re:Or by Kagami001 · · Score: 2, Informative

    The 2000 degragger doesn't defrag the MFT, but the XP defragger does.

    XP still has no buit-in method of defragging the pagefile or registry hives, however.