Slashdot Mirror


How Much Virtual Memory is Enough?

whitroth asks: "Ten years ago, Received Wisdom said that virtual memory should be, on the average, two to two-and-a-half times real memory. In these days, where 2G RAM is not unusual, and many times is not that uncommon, is this unreasonable? What's the sense of the community as to what is a reasonable size for swap these days?"

544 comments

  1. lots by emphatic · · Score: 5, Funny

    lots

    1. Re:lots by Xocet_00 · · Score: 0, Offtopic

      Haha. Redundant.

      I'm not really sure it's possible for the first thing said in a discussion to be "redundant".

      Weee! Now I'm going to get an "offtopic". Sweet.

    2. Re:lots by Millenniumman · · Score: 0, Redundant

      This would be a redundant first post:

      "Ten years ago, Received Wisdom said that virtual memory should be, on the average, two to two-and-a-half times real memory. In these days, where 2G RAM is not unusual, and many times that not that uncommon, is this unreasonable? What's the sense of the community as to what is a reasonable size for swap these days?"

      --
      Stupidity is like nuclear power, it can be used for good or evil. And you don't want to get any on you.
    3. Re:lots by Xocet_00 · · Score: 0, Offtopic

      He gets offtopic too? Not all slashdot discussions confine themselves to only the immediate topic discussed in the article. I'd say by the third post, we've got a legitimate discussion going. Pfft.

    4. Re:lots by Anonymous Coward · · Score: 0

      Quit bogarting the off topicy goodness, you insensitive clods!

    5. Re:lots by Anonymous Coward · · Score: 1, Informative

      A gig of RAM costs 50 times more than a Gig of HDD.

      With this in mind, the no brainer option would be to set an extra-large maximum swap file size and then set your computer to only use it when absolutely neccessary (e.g. in windows use "ConservativeSwapFileUsage = 1" in system.ini). Minimum chance of running out of memory space, minimum unneccessary slowdown.

  2. Not much, anymore... by FishWithAHammer · · Score: 5, Insightful

    Under Windows it seems it'll swap out whether the free RAM is needed or not, no matter what (there's a registry setting to change this though). Under Linux, you won't swap much anyway unless you need it.

    I run a Core Duo laptop with 1GB of RAM and have never swapped out in Linux, no matter what I was doing.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
    1. Re:Not much, anymore... by Propaganda13 · · Score: 5, Informative

      Simple. Monitor your own resource usage and figure out what YOU require. Everyone has different hardware, programs, and habits.

    2. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      What needs to be edited in the registry to stop the swaping out of RAM?

    3. Re:Not much, anymore... by Xocet_00 · · Score: 1

      What registry entry is that? I'd love to be able to spin down my disk (laptop w/ 1.5GB) occasionally while in Windows. Something always seems to be swapping.

    4. Re:Not much, anymore... by larry+bagina · · Score: 5, Informative

      system control panel -> advanced -> performance options -> advanced - > virtual memory.

      Set to no paging.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    5. Re:Not much, anymore... by toller8 · · Score: 3, Insightful
      Different jobs, different needs....

      Two of my (Linux) servers have lots of memory and lots of small processes so anything that does swap out swaps out quick. These don't use a lot of swap (512Mb?) and don't have gig sized processes to write into swap... so they don't really need the 2+ gig of allocated swap.

      One other (Linux) server has big processes (1Gig or more) and when they have to swap out, watch the machine fall apart while the process is swapped out - it takes a while to write 1 gig of ram into swap! Since the process is large, swap needs to be large.... Just hope that server needs to have 3 or 4 multi gig processes swapped out....

      So, YMMV! Know your machines and what *may* need to swap out and you can live on the edge and figure your minimum swap.... or you could be safe and boring and have x.5 times RAM... After all... who needs that critical app to run after memory gets tight and the kernel kills it cause it was the memory hog?

      :)

      --
      Any comment....
    6. Re:Not much, anymore... by KingJoshi · · Score: 1

      Exactly. And being on a laptop, the HD speed is slower and a complete waste of battery and time. So I have ZERO virtual memory. On Linux it'd be a different story because it's smart enough not to needlessly swap. I barely go over 500 MB, unless I'm playing Civ4, in which case it might go to a gig. But with 2GB RAM, why does Windows swap so much? Well, for me, not any more.

      --
      In times like these, it is helpful to remember that there have always been times like these. - Paul Harvey
    7. Re:Not much, anymore... by megaditto · · Score: 5, Informative

      To control how much 'it will swap' on Linux:
      #echo [0-100] > /proc/sys/vm/swappiness

      A better question is how much memory you can address. Could your 32 bit Windows system address over 2^36 bits of memory (64GB), for example? And could you allocate over 2GB to windows kernel?
      Could your 64-bit linux system address over 2^48 bits of memory?

      --
      Obama likes poor people so much, he wants to make more of them.
    8. Re:Not much, anymore... by SanityInAnarchy · · Score: 3, Informative

      Swapping out makes sense sometimes, though. For instance, there are tiny chunks of the system -- daemons and such -- that are pretty much never accessed. I'd rather reclaim that, if only to cache something worthwhile.

      Also, remember that suspend2 requires swap, so figure how much of an image you'll need (and how much is cache that can be freed) and get a bit more than that. My own rule of thumb is, swap is roughly 1x to 1.5x RAM, so that I can be sure I have room for the suspend. But I have the space, and Windows doesn't use swap for this anyway, it uses hiberfil.sys

      --
      Don't thank God, thank a doctor!
    9. Re:Not much, anymore... by LiquidCoooled · · Score: 3, Informative

      This works really well until the one day you leave everything running, startup halflife and flick around the levels (uses memory faster...)

      bleeding thing cannot smoothly say "You are running out of memory, Setting up an emergency page file now...." without something crashing.

      Fix this problem and you are cooking on gas. A modern computer should be able to accomodate every malloc upto memory+free disk space and it can't easily.

      --
      liqbase :: faster than paper
    10. Re:Not much, anymore... by Ctrl-Z · · Score: 1

      I suppose that depends on what you're doing with it. First of all, not all laptops have slow hard drives. Secondly, if you're using a laptop as a developer, it's pretty easy to eat up 2GB of RAM. Especially if you're running Oracle, SQL Server, and several instances of various pieces of server software. I was surprised when I recently discovered that when SQL Server is doing a lot of stuff, it will continue to allocate memory until you have 4-10 *MB* left. That is, unless you find the advanced option to cap the memory usage.

      --
      www.timcoleman.com is a total waste of your time. Never go there.
    11. Re:Not much, anymore... by mnmn · · Score: 1

      Core Duo?

      You havent used the laptop long enough.

      --
      "Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
    12. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      So I have ZERO virtual memory.

      How did you manage that? Windows seems to force a minimum of a 2 megabyte pagefile.

    13. Re:Not much, anymore... by Tatsh · · Score: 1

      100% agreed. I have never gotten a problem after setting this on my previous desktop and new laptop, both which have 1GB of RAM.

    14. Re:Not much, anymore... by Transcendent · · Score: 1

      You've never run Matlab for a big project, I take it...

    15. Re:Not much, anymore... by lnjasdpppun · · Score: 1

      Disable the page file completely. It's an option in the same screen where you set the page file size.

      I've had Windows ignore my first request to disable the page file before, but as is the way with Windows telling it twice actually got the message through.

    16. Re:Not much, anymore... by gameforge · · Score: 3, Interesting

      A modern computer should be able to accomodate every malloc upto memory+free disk space and it can't easily.

      I see. So how do you get around that little address space issue? I'm quite certain a regular 32-bit PC w/ 4GB of RAM doesn't need a swapfile unless you're running Linux (and an AWFUL lot of software, or software with VERY large RAM requirements). Even in that case, it's a special kernel option, and if you can actually max your 4GB of RAM to the gills by multitasking regular, every-day software, you deserve to be penalized with sluggish performance! Okay no, but still.

      Since RAM is dirt cheap anymore, everyone really should have 4GB on their 32-bit computers for the sole purpose of turning their swapfile off; it's probably the least amount of money you could spend per the increased performance in Windows.

    17. Re:Not much, anymore... by irritating+environme · · Score: 2, Interesting

      I have not run this option, but most people indicate that Windows is totally built around assuming there's a swapfile, and doesn't properly handle not having a swap file in an optimized manner. Enough seemingly-smart people have indicated this that I don't do it.

      I think most people's issues with this is that there aren't a lot of good options in windows. Either you deal with their crappy swapping decision algorithms, or you go without swap in an OS that has assumed swap has been there for about a decade.

      --


      Hey, I'm just your average shit and piss factory.
    18. Re:Not much, anymore... by shaitand · · Score: 1

      4GB of memory is about $400+, $400 is the cost of the entire computer for most users. How could you possibly claim that everyone should have 4GB?

      "I'm quite certain a regular 32-bit PC w/ 4GB of RAM doesn't need a swapfile unless you're running Linux"

      Running Linux does not require more memory, actually it is the opposite.

      I would however have to agree that avoiding swap is a way to bypass the worst bottleneck in modern computers. Right now the harddrive extremely limits performance on windows where swap is an all or none issue rather than a none unless needed issue. I hear people discount drive performance all the time as if it has no significant effect on performance but when your computer is running swap all the time then your memory speed is effectively reduced to the speed of a drive that is drastically slower.

    19. Re:Not much, anymore... by Daxster · · Score: 1

      4GB of memory is about $400+, $400 is the cost of the entire computer for most users. How could you possibly claim that everyone should have 4GB?

      Not quite $400. Although it's not far off ($300, although a friend of mine purchased 2GB for $80 from newegg), you argument is slightly fallacious. "Most users" don't need 4gb of ram because of the price, but because they have no need for it. Gaming is still comfortable at a quarter of that or less.

      --
      Death by snoo-snoo!
    20. Re:Not much, anymore... by debiguana · · Score: 1
      "I'm quite certain a regular 32-bit PC w/ 4GB of RAM doesn't need a swapfile unless you're running Linux" Running Linux does not require more memory, actually it is the opposite.
      I believe the parent post was referring to the same, clarifying that the only time you would actually need that much memory was if you were doing something extremely resource intensive, like, say, doing scientific research calculations, or VMware'ing windows on top :)
    21. Re:Not much, anymore... by x_MeRLiN_x · · Score: 0

      If you're using Windows, this is already done for you, and as the grandparent says, it's rare for you to use your swap file under Linux. The only method I could think of is if you set the physical cache size in Google Earth to the maximum value permitted.

    22. Re:Not much, anymore... by Gareth+Williams · · Score: 1

      Actually, I get the feeling that the meaning the GP was shooting for was that you can't usually address more than 4GB of memory at a time (it's an address space issue), so above 4GB there's no point adding more RAM *or* swap, cos you can't address it ;)

      However, if you run linux you can flip on your "I've got more memory than any sane person knows WTF to do with" kernel option, recompile, and you get a much bigger address space.

      --

      --Gareth
    23. Re:Not much, anymore... by SirTalon42 · · Score: 1

      suspend2 doesn't actually use swap, it just needs a partition or file to push everything out to for while its suspended (and the common solution is to push it out to a swap partition)

    24. Re:Not much, anymore... by nazsco · · Score: 1

      after getting 2gb and having a slot HD: tried to remove it from windows. only that it wouldn't allow you to!

      i even tried creating a ram disk and putting the swap there. but aparently i it needed swap before loading the driver. never got it to work

      now i'm back to linux. have 1gb of swap. never even got close to touching it!

      sometimes i even umount, mkfs, and unzip large files to it so i don't risk fragmenting my main data partition :)

    25. Re:Not much, anymore... by LO0G · · Score: 4, Informative

      VM != VA. You're confusing the two.

      VA is Virtual Address space. For a 32bit processor, you have 32bits of virtual address space - each process can occupy no more than 3G of RAM (on XP, with the /3G switch (which can hurt other parts of the system because it reduces the memory that the kernel can use)).

      If you have more than one process, you have more than one virtual address space. So saying that each process can only address 3G of RAM doesn't matter - with 30 processes running, you could theoretically have 90G of VA allocated.

      What's important is VM.

      VM is vitual memory. VM is what backs the pages that are mapped into the VA.

      The maximum amount of VM you can have allocated on a machine is measured by the commitment limit on the machine, which is typically measured as "physical RAM + page file space". If overall VM always stays below physical RAM, you don't need a paging file. But if it EVER goes above it, you're toast if you don't have a paging file. All those pages from the boot process that normally would have been discarded to the paging file (or were allocated by daemons that started during boot but haven't done anything since then) stick in the craw of the memory manager taking up space that COULD be used for your application, but can't because you've not told the OS where to put them.

      That's why you have a paging file - it gives the OS a place to put the mouldy old pages that were allocated by apps that aren't actively doing things so your application can re-use the memory that those apps were using.

      Btw, it's my understanding that ALL modern virtual memory based operating systems have essentially the same VM architecture - Linux, Windows, whatever. They both use paging files for essentially the same things - discarding writable pages that are not in current use by applications (read-only pages can typically be loaded from the binary image).

    26. Re:Not much, anymore... by merlin_jim · · Score: 1

      Under Windows it seems it'll swap out whether the free RAM is needed or not

      That's correct - the pagefile in Windows is a direct memory map with a dirty write cache, it is always being updated to reflect currently running processes, and there's a mapper behind the scenes that maps pagefile space to physical addresses. Swapping is done by simply unallocating the memory from the pagefile, when it's needed it's paged back in.

      Fundamentally, for Windows to operate well, your pagefile should be larger than your physical memory by some amount. I personally on a 2GB system would set it to memory and set autogrowth on - you'll probably never need it, but if you, you've given Windows an escape option to continue running...

      It's very inefficient, but supports among other things complete bluescreen debugging, because the entire state of the machine is theoretically on disk after system recovery...

      I personally agree with the Linux model - just use the swap when you need it, don't weigh down my drive with useless chatter.

      --
      I am disrespectful to dirt! Can you see that I am serious?!
    27. Re:Not much, anymore... by shaitand · · Score: 1

      I think you are probably correct about the intended meaning. The bit about the kernel option gives it away. I really only answered what he said (as opposed to what he meant) to cast a wider net.

      I probably could have thrown my own general rule of thumb for swap as well. 2x memory if you have less than 256mb memory and then 50% of physical memory above that. I have found that this configuration minimizes swapping. With a larger swap file the system seems to need more free physical memory to enable swap (or to enable it sooner). At least that is my rule of thumb on linux. On windows you should generally allow the system to manage swap.

    28. Re:Not much, anymore... by postmortem · · Score: 1

      Score 5 for this comment? Windows can't live without swap memory. 0 is automatically ignored (and other small values), and Windows decides to use as much as it wants. This is easily verified by running DirectX Siagnostic Tool, dxdiag.exe.

      In Windows 2000/XP you can't disable swap memory- plain and simple. Swap size can be reduced, that's all, but Windows will only follow your seeting until need arises (and that won't be when Windows has ran out of RAM, as other have explained).

    29. Re:Not much, anymore... by Fordiman · · Score: 1

      "Under Linux, you won't swap much anyway unless you need it."

      If you're like me, you have about half your ram committed under /tmp (really kicks up performance on things like Firefox, that keep many small files around). This means, of my 512, 256 is usable by X/KDE (which automatically chomps up a good 192 of it).

      If I had 2G, I'd not have this issue at all, mind you. Still, I wouldn't mind giving up 5G for swapspace either; HD size is just boosting so much more quickly than RAM size per dollar that this discussion is completely academic.

      --
      110100 1101000 1101000 1100110 0 1101111 1101000 1100011 1
    30. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      I have a P1 with 72MiB of RAM. Even running an old version of the GIMP on Red Hat 5 or 6, it has never used swap.

      I've heard of programs that will make swap files if you need them in an emergency.

    31. Re:Not much, anymore... by Com2Kid · · Score: 1

      and if you can actually max your 4GB of RAM to the gills by multitasking regular, every-day software, you deserve to be penalized with sluggish performance!


      A few high resolution photos loaded up into an editor and that 4GB of RAM is gone rather fast.
    32. Re:Not much, anymore... by SanityInAnarchy · · Score: 1

      I don't actually know how it works, but I do remember how it used to work -- the older software suspend was incredibly slow because it tried to free as much cache as possible, then swap as much out as possible, so the actual image would be as small as possible. I'd argue that it still kind of makes sense to be able to swap some stuff out before suspend -- you may not need that space on resume.

      But then, the newer suspend is fast, because it writes out just about everything, and it all gets loaded in one sequential disk read -- I wish it'd trim the caches some, though.

      Oh, question -- how would you write out to a file on a partition in-use? Aren't you supposed to not touch in-use filesystems, otherwise Bad Things Happen?

      --
      Don't thank God, thank a doctor!
    33. Re:Not much, anymore... by TheNetAvenger · · Score: 3, Insightful

      Score 5 for this comment? Windows can't live without swap memory. 0 is automatically ignored (and other small values), and Windows decides to use as much as it wants. This is easily verified by running DirectX Siagnostic Tool, dxdiag.exe.

      In Windows 2000/XP you can't disable swap memory- plain and simple. Swap size can be reduced, that's all, but Windows will only follow your seeting until need arises (and that won't be when Windows has ran out of RAM, as other have explained).



      Actually they can be turned off in WindowsXP, easily, with no problems what so ever if you have a large memory footprint.

      In fact, the way Windows DOES handle memory it is better at running without a paging file than most OSes because it will not shove in crap loads of content to the pagefile anticipating the application will use it.

      Windows Vista also can and will run will without a pagefile, without incident.

      Where windows has 'sucked' at pagefiles in the past is that it will give priority to file operations that are non-application load related and use the RAM Cache, thereby paging existing applications to the Hard Drive. (This is changed in Vista, file copy operations should no longer consume RAM Cache at the expense of applications.)

    34. Re:Not much, anymore... by spongman · · Score: 2, Informative

      start TaskMgr.exe, go to the processes tab, View->Select Columns: "I/O Reads", "I/O Writes". Sort by Process Name, wait a while, see which processes are still reading/writing. Kill them.

    35. Re:Not much, anymore... by welshsocialist · · Score: 1

      I thought that virtual memory was done away with Mac OS X compared with Mac OS 9? Or is there something i'm mixing up here?

      --
      Support the Chagossians
    36. Re:Not much, anymore... by gameforge · · Score: 1

      You sure? A 3000x2000 image @ 32bpp would consume roughly 23MB uncompressed: 3,000 * 2,000 = 6,000,000 * 4 bytes per pixel = 24,000,000 bytes / 1024 = 23,437.5 kilobytes / 1024 = 22.888 megabytes. Even 2GB is enough to have about 90 of those uncompressed, high resolution photos in memory at the same time. 2GB is enough to store almost 7 days of UNCOMPRESSED cd quality digital audio: 2^31 bytes / (44,100 * 2) bytes per second. Still, what's Windows going to do about it? Swap or not, 4GB is the address barrier on every day systems with 32-bit Windows.

      Incidentally, most graphics software is very smart and has its own internal paging system for this very reason; it won't even consume all of your 4GB if you tried, in all but ridiculous/silly (and very un-everyday like) situations. With no personal experience, I would guess most video editing software is the same way. Running out of memory is a somewhat dangerous thing to do, particularly to Windows.

    37. Re:Not much, anymore... by mathew7 · · Score: 1

      First of all, 32-bit processors cannot access more than 4G of memory. Some newer processors have PAE (Physical Address Extension) which enables them to use more, but it's slow and not really useful/used in desktop. Another problem is that physical addresses between 3.6GB and 4GB are used by PCI mappings. So you will never be able to use the full 4GB RAM.

      The thing which I hate about Windows XP (and 2000 and NT) is that I cannot limit the cache size (like in Win9x/ME). So if I have 20 applications open which do nothing and then copy some large files (like 1 file the size of my RAM), it will page all of my applications to swap, although the cache data is used only once. And when I get back to my applications I have to wait. Also, the Windows File Sharing cache is treated differently to the system cache. The systems sees it as a normal application. So if you play something (FPS) and someone starts to copy a large file over the network from you (like a 700MB file when you have 1GB), you will not be able to play (even at 10Mbits/s). If the transfer is done using a ftp server, you barely notice (even at 100Mbits/s), but with "server" service, it kills you.
      So I'm not using a pagefile just to force the cache to not "swap-out" other apps. But if I have a memory leak from an application (or apps which really use a lot of memory), I do get in trouble. It did happen a few times.

    38. Re:Not much, anymore... by dierdorf · · Score: 1
      You sure? A 3000x2000 image @ 32bpp would consume roughly 23MB uncompressed: 3,000 * 2,000 = 6,000,000 * 4 bytes per pixel = 24,000,000 bytes / 1024 = 23,437.5 kilobytes / 1024 = 22.888 megabytes. Even 2GB is enough to have about 90 of those uncompressed, high resolution photos in memory at the same time. 2GB is enough to store almost 7 days of UNCOMPRESSED cd quality digital audio: 2^31 bytes / (44,100 * 2) bytes per second. Still, what's Windows going to do about it? Swap or not, 4GB is the address barrier on every day systems with 32-bit Windows.

      "Six megapixels" and "high resolution" do not belong in the same sentence. If you had said a hundred megapixels, I might agree with you. Then you could have (400 megabytes) x (15 layers and masks) x (30 backups in the "Undo" stack)... I think you can eat memory (and then swap) very nicely under those circumstances, just for one image. (And no, a 400 megabyte raw image is not ridiculous -- try scanning a 6x7 cm transparency at 4000 dpi and see what happens!)

      --
      -- John Dierdorf, Austin TX
    39. Re:Not much, anymore... by lazybeam · · Score: 1

      I remember back in the day I had 512MB of RAM; which was at least twice as much as any of my friends at the time, and to speed things I up turned off swap completely. It went faster then, running Windows98, until I tried to start Quake 2. Q2 actally requested swap space (only about 16MB IIRC) but because I had none it stopped with an error...

      Now with XP, minimising stuff with 512MB RAM and swap causes that app to be swapped out, even minimising and walking away ("Blank Screen" screensaver) coming back 30 minutes later can take several seconds to restore the window. I turned swap off on that machine and haven't found a problem yet (when upgraded to 1GB RAM) but that is my fiance's computer now and she really just uses MSN and plays Neopets. This laptop running Ubuntu feels more snappy at any time (512MB RAM), even when speed-shaped down to 600MHz.

      --
      --
      no sig for you. come back one year.
    40. Re:Not much, anymore... by mathew7 · · Score: 4, Informative

      "One other (Linux) server has big processes (1Gig or more) and when they have to swap out, watch the machine fall apart while the process is swapped out - it takes a while to write 1 gig of ram into swap! Since the process is large, swap needs to be large.... Just hope that server needs to have 3 or 4 multi gig processes swapped out...."

      You seems to miss the idea of swap. All modern OSes combined with processors (from 386 in the x86 range) will swap 4KB pages. So if memory is needed, the last accessed page (4KB) in RAM will be swapped (and the algorithm continues until no more RAM is required). When one of the swapped 4KB pages is needed, it's retrieved from swap in free RAM (if no free RAM is available, it swaps out another page).
      I don't think it swaps out all of your application, and if it does, you should increase you RAM. The thing is that your app can try to access the "just swapped" page, which is a preformance killer. Swapping is done on page chunks, not app chunks.
      PS: the term pagefile probably comes from windows 95 because it contains "pages". All modern processors have MMU (http://en.wikipedia.org/wiki/Memory_management_un it), which segments the memory in 4-64KB of pages.

    41. Re:Not much, anymore... by Anonymous Coward · · Score: 1, Insightful

      Why in the name of Pete does the kernel just *kill* anything, ever??? I know of no real unix, or unix clone, that does this. Who was smoking what when they decided: "Out of memory? Kill something!"????

      JP

      P.S. That's a serious question, not a troll...

    42. Re:Not much, anymore... by qazsedcft · · Score: 2, Informative

      In Windows 2000/XP you can't disable swap memory- plain and simple. Swap size can be reduced, that's all, but Windows will only follow your seeting until need arises (and that won't be when Windows has ran out of RAM, as other have explained).

      You apparently do not have a Win XP SP2 machine to check this out. In the control panel there is an option "No page file" which is not the same as setting the size to zero. I've been running my machine without a pagefile for over a year without any problems whatsoever.

    43. Re:Not much, anymore... by bavodr · · Score: 1

      What would that registry setting be? I am really interested in this. I have 1.5GB of RAM and rarely use more then 1GB of physical RAM. Windows is still swapping too much. I do not want to disable the pagefile completely however, just make it swap less when free RAM is still available.

    44. Re:Not much, anymore... by Fulcrum+of+Evil · · Score: 2, Interesting

      Could your 64-bit linux system address over 2^48 bits of memory?

      Doubt it. I think AMD64 tops out at 41-42 address lines right now.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    45. Re:Not much, anymore... by mpiktas · · Score: 1

      Yeah, R also. Try nlme with hundred iterations and enjoy:)

    46. Re:Not much, anymore... by Nefarious+Wheel · · Score: 1
      Pagefile and swapfile go back a bit further than W95 -- two separate entities in VMS. Paging was for small granularity swaps, on a least-recently-used basis. The swap file was for whole processes, where nothing but the process header was left in memory. Image activation was very efficient -- it didn't read the whole executable into RAM, it just marked where it was and demand-paged it in. Considering how expensive and limited memory was in the 1980's, it was a good system. I still like VMS, even after years of win/lin servers and desktops. The sucker just works, and I still dream of logical names coming back into favour. It didn't do quite as much for you as more modern implementations but if you organised it correctly, you were very much in control of things and you could keep it running and safe.

      How much VM was safe? As GP said, it varies. But I do remember that extending the page or swap file was a bit overhead-intensive, so the hot tuning tip was to figure out a good max value and use it for both min and max values to keep the system from remapping it's page tables. I think the same technique works well on Win2K & upward (a fair bit of their memory models were derived from VMS, by agreement between MSFT and DEC), not sure about the efficiencies of unix* based systems but it might work as a tuning tip (YMMV, and remember Tuning Tip #1 -- MEASURE it!)

      *Bite me, SCO -- I'll call it what I want.

      --
      Do not mock my vision of impractical footwear
    47. Re:Not much, anymore... by dark_knight_ita · · Score: 1
      Under Linux, you won't swap much anyway unless you need it.
      Like if you're compiling OpenOffice.org ;)
    48. Re:Not much, anymore... by gameforge · · Score: 1

      "Six megapixels" and "high resolution" do not belong in the same sentence. If you had said a hundred megapixels, I might agree with you. Then you could have (400 megabytes) x (15 layers and masks) x (30 backups in the "Undo" stack)... I think you can eat memory (and then swap) very nicely under those circumstances, just for one image. (And no, a 400 megabyte raw image is not ridiculous -- try scanning a 6x7 cm transparency at 4000 dpi and see what happens!)

      It was an accident. The computer eventually became conscious again. But I think it was 12000 dpi, and I think it was a larger file than that, in fact I think it barfed at the file size it was going to have to produce (2GB I'm guessing).

      I really don't have a use for scanning anything at that resolution. I have a 3.2 megapixel Olympus camera which takes shots that are high resolution enough to produce a very good looking printed photograph which is a respectable size. I scan stuff like baseball cards, old photograph negatives, text and forms, model textures, things like that. To me, 3000x2000 is enormous. I realize I'm not a graphics guy or anything... but I probably do more than what I'd call an "average" user.

      Here's a 10 megapixel photo of Mars.
      Here's a 6 megapixel photo of the new lava dome inside of Mt. St. Helens.

      Those are not "low" or "medium" resolution to me.

    49. Re:Not much, anymore... by paganizer · · Score: 5, Informative

      Here is The True Word from a MCSE of long standing on the subject of virtual memory and windows (please note that nearly every person who has worked with windows will have a different true word):
      All windows: defrag your drives first.
      Win98SE: if RAM is =/> than 256mb, make Min setting equal to the amount of RAM, Max set to 1.5 the amount of RAM.
      If less than 256mb, set min setting to 1.5 times amount of ram, max to 2.5 times or 512MB, whichever comes first.

      Winnt:
      if you have 2 drives (not two partitions, two drives) create swap files with min/max equal to the amount of physical memory in the system on 2 drives. This is a way to make WinNT scream when it comes to disk writes
      Otherwise, if RAM is less than 256mb, set Virtual memory, both min & max, to twice your amount of RAM; if you have => 256MB, set min & Max to 1.5 times the amount of RAM.

      Win2k: if you have less than or equal to 512MB, set min to 1.5 times RAM, max to 2 times RAM. if you have greater than 512mb, set swap min/max to 1.5 times RAM.
      If you ever get an "out of virtual memory" error, defrag and add 100mb to min/max.
      If you have =/> 2GB RAM, disable swap, unless you are running server, in which case 4GB is the magic number.
      The 2 drive swap method just doesn't seem to work as well on Win2k as it did on WinNT; no clue why, but i've tested it repeatedly.

      WinXP Pro: Luser. why are you running the Windows ME of the 21st century? at least you aren't running WinXP home, though. just follow the guidelines for win2k, since that is all WinXP pro is, win2k with add-on crap, no changes to kernel or underlying function.

      Win2003: No clue.

      Vista: Not only have no clue, but I promise you I never will.

      --
      Why, yes, I AM a Pagan Libertarian.
    50. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      Your too busy running cache bound benchmarks bro try working with a 2G database or DVD sized files??

    51. Re:Not much, anymore... by Vlad_the_Inhaler · · Score: 2, Informative

      That would make a nice variation on those 'BSD is dead' trolls - 'BSD kills your memory hogs'.

      I work under a mainframe OS and before VM was introduced (20 years ago?) the OS would happily swap processes or unused parts of processes out, it would kill any process which tried to allocate more memory than was physically available.

      --
      Mielipiteet omiani - Opinions personal, facts suspect.
    52. Re:Not much, anymore... by isorox · · Score: 1

      Under Linux, you won't swap much anyway unless you need it.

      We've got a strange unsupported application that grabs 80% of physical memory and sits there using it. Unfortunatly the kernel that was supplied (2.4.20) seemed to have some bug where swap got used, and get freed. 2.4.32 seems to have solved the problem.

    53. Re:Not much, anymore... by mrbcs · · Score: 1

      I have a gig of ram on an Athlon 64 3000 with win2k. I can run for over a week at a time and not notice any swapping. Shutting off the swap is asking for trouble though.

      --
      I'm not anti-social, I'm anti-idiot.
    54. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      "a regular 32-bit PC w/ 4GB of RAM doesn't need a swapfile unless you're running Linux" ... wel a regular, 32Bit PC with regular 32bit Windows XP can only deal with 2Gb of RAM....

    55. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      Summary: "My Windoze swaps, my linux doesn't." I assume you never tried rendering a really complex scene on your Linux box, have you? It'll swap its ass of as well when you've only got 1GB of RAM.

    56. Re:Not much, anymore... by gameforge · · Score: 2, Informative

      You're right about all of that, except that no 32-bit OS should be forced to deal with more than 4GB of physical address space.

      One of the above posts outlines exactly what the min. and max. settings for each version of Windows' pagefile should be, except of course XP's. :) Still, with XP, the max pagefile size combined with your total RAM size is not more than 4GB by default. This is on purpose. If all of the process' virtual to physical memory maps contain unique addresses within a 4GB address space, then Windows doesn't have to go through the map and adjust every address every time the program is swapped one way or another. In reality, as you approach the limit, it still will; but at least if all the tables are in chip and ready to go, it's speedy about it.

      With WinXP, you can have 4GB of RAM and another 4GB of pagefile space and total an 8GB commit limit (and that is the REAL limit without PAE); however, as said, doing so slows it down.

      PAE is faster (but not as fast as 4GB actually exists or not - you can even do /NOLOWMEM to ensure that device drivers get fed 64-bit physical addresses). Run some benchmarks.

      You can safely put 4GB of RAM into your computer and forget about pagefiles. Windows will love you for it.

    57. Re:Not much, anymore... by Anonymous Coward · · Score: 2, Informative

      Not true at all. The WinXP kernel is significantly different from the Win2K kernel with one very important area of memory management. The Win2K kernel kept the registry hives in the paged pool. This means they took up kernel address space and prototype PTE entries. As a side effect this limited the number of hives in the system which was problematic for terminal services.

      WinXP and newer do something similar to the NT cache manager and map hive views in and out as they need them. This means that WinXP can deal better with low memory pressure in terms of pageable kernel data.

      So the rules for setting up optimal swapfiles are different between XP and 2K.

      Sorry, but MCSE is no match for somebody familiar with the kernel in detail. :)

    58. Re:Not much, anymore... by jrumney · · Score: 2

      Address lines are for addressing physical RAM. Virtual memory is not limited by the availability of address lines. Many older (386, 486) cpus could address 4Gb of virtual memory, but only had 26 or 28bit address lines for example, so were limited to 64Mb or 256Mb RAM, which was far more than most people could imagine using.

    59. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      ... wel a regular, 32Bit PC with regular 32bit Windows XP can only deal with 2Gb of RAM....

      i like the part where you just pull facts out of your butt.

      let's try including a source or two with our random assertions.

      all XP's except for x64 support 4G of RAM; XP x64 supports 128G.

      that's 2G of user space and 2G of kernel space.

      both are your friend, and both can reside in physical RAM.

    60. Re:Not much, anymore... by gameforge · · Score: 1

      Wow, screwed that one up. I must be kinda tired. :)

      What I meant to say was this:

      "PAE is faster (but not as fast as 4GB actually exists or not - you can even do /NOLOWMEM to ensure that device drivers get fed 64-bit physical addresses). Run some benchmarks."

    61. Re:Not much, anymore... by packeteer · · Score: 1

      I find that i personally dont need more than 1GB of ram so i purchased the fastest/lowest latency ram i could get and i still probably spent less than many people do on ram. I know 1GB is nto enough for many people but its all i ahve ever needed and i notice quite a system performance boost with FAST ram instead of just a LOT of ram.

      --
      unzip; strip; touch; finger; mount; fsck; more; yes; unmount; sleep
    62. Re:Not much, anymore... by gameforge · · Score: 1

      Good God, stupid forum nonsense... It's certainly a dead horse now (and I'm a little embarassed :)

      Incidentally, /. doesn't like the lesser than sign if, at some later point, you have a greater than sign. It thinks you're making a tag, even with Plain Old Text selected!

      One more time, if I wasn't already going to be modded to oblivion:

      "PAE is faster (but not as fast as less-than or equal-to 4GB). If you don't believe me, you can boot Windows with /PAE and load the 64-bit address kernel whether PAE or greater than 4GB actually exists or not - you can even do /NOLOWMEM to ensure that device drivers get fed 64-bit physical addresses). Run some benchmarks."

      I even used the damn preview button and everything...

    63. Re:Not much, anymore... by zoney_ie · · Score: 1

      Nah - Vista will be the true Windows ME of the 21st century. XP Pro is the patched version of 2K (albeit with silly stuff chucked in like the fisher-price interface - but what sensible person uses that?!)

      Interestingly, I haven't had Windows bluescreen on me since way back when I used Win 95 and NT4. The latter only did so a handful of times, and it was likely due to poor hardware support (read, the OS didn't cope with crappy hardware).

      It's annoying how long it takes to sanitise XP after install mind you. I don't mind using 2K, but as you say, they are much the same. I'm happier with the more up-to-date OS considering it's not costing me money (came with new PCs in work + home, so all I had to do was make sure I didn't get the Home version or even more worringly, XP "Media Centre Edition").

      --
      -- *~()____) This message will self-destruct in 5 seconds...
    64. Re:Not much, anymore... by Crunchyfroglegs · · Score: 1

      Well, I'm running XP Pro, and I only Have 768, i killed my page... and everything runs faster, including the mouse...

    65. Re:Not much, anymore... by LainTouko · · Score: 1
      Simple. Monitor your own resource usage and figure out what YOU require. Everyone has different hardware, programs, and habits.
      I think this topic is intended to help those to whom that isn't simple.
    66. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      It will happen with most OSes that overcommit memory. Including FreeBSD for
      example (yes freebsd has an oom killer).

      Another opion is to not overcommit (Linux can do this), or overcommit but
      panic and halt or reboot on oom (Linux can also do this).

      It really isn't a big deal.

    67. Re:Not much, anymore... by Anonymous Coward · · Score: 0
      XP Pro is the patched version of 2K (albeit with silly stuff chucked in like the fisher-price interface - but what sensible person uses that?!)

      Remote desktop/remote assistance. That's XP's killer feature. Unless you've got 2K server you don't get that, and even then you only get 256 colours remotely.

      For home users there's fast user switching. You can't get that on 2K. And XP SP2 added much security goodness you shouldn't be without. And there's no 64-bit version of 2K (unless you're running Itanium).
    68. Re:Not much, anymore... by carl0ski · · Score: 1

      Thats probably why linux works much better on battery life than windows
       
      I only have 256MB Ram

      and on batteries

      Each day i have a long trip to work

      consists of get on train sit and type reports on my laptop.
      chuck it back in the bag

      use it on the train going home
      comes between 2 & 2 1/2 hours each day

      under Ubuntu 6.06 i can to and from work on the train and still sit down at home with it.

      Windows XP clearly doesnt like 256MB and battery dies halfway through my train trip home

      now i only use linux on my laptop.

    69. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      Unless you change its default configuration (tile_cache_size), GIMP will never use more than 64 MB or memory and will do its own disk swapping. So I am not surprised that your swap partition or swap file was never used...

    70. Re:Not much, anymore... by TheThiefMaster · · Score: 1

      Windows Server 2003 is pretty much XP with extra crap thrown in (seriously, if you want to say that some of the serious improvements in XP over 2k are "add-on crap" making it the "ME of the 21st century", then go ahead. I think that ME was a failure because it was unstable, not because of the features they added. With XP I think I'll keep my free built-in cd burning ability and the fact that it actually has drivers for the old integrated radeon in my sister's pc. I've even seen XP running on a pentium 166 with 128MB of ram without swapping, and it was still pretty responsive, although I'll admit it was using ALL the ram and we didn't try running anything, especially not office.)

      Windows Server 2003 is pretty much the same kernel as XP, with a few extra things turned on, such as supporting more cpus, extra types of software raid etc, and some things off by default, such as the XP skin and the quick tasks side-panel in explorer. Basically set swap to how much you need, but in a server you should have the space for 4GB swap easy.

      It's also a good idea not to set the swap min and max to the same number, because having your server dies horribly the moment it fills its swap is not good. I recommend setting the max to 2x the min, regardless of how much you have, as long as you have the drive space.

    71. Re:Not much, anymore... by Daytona955i · · Score: 1

      If you want a < sign, use & lt ; (without the spaces) and for > use & gt ; (without the spaces).

    72. Re:Not much, anymore... by squiggleslash · · Score: 1

      When you say "lots of small processes", do you mean "I'm generally using a few hundred megs, but I'm running a few hundred processes so that's pretty good" (ie you're using a significant percentage of your memory, but nowhere near enough to worry about getting more) or do you mean "I run 30 or 40 processes each of which is maybe a meg at most"? (ie virtually all your memory is free, the amount you added was overkill)

      I ask because it's a peculiarity of Linux, and some other VM implementations, that it's frequently better to have swap in the first situation than not have it. Why? Because of disk caching. VM allows the kernel to swap out idle processes (or idle memory from processes anyway) in favour of caching the sectors of recently processed files. This can make for dramatic speed-ups. For a desktop workstation, this can be good and can be bad, a search through a bunch of files that make up a large part of the disk can cause every major application to crawl as they're reloaded into memory.

      But in your example, (a) you're not using it as a workstation, you're using it as a server (which tends to imply it'll be much more file intensive) and (b) you're running small processes, not large ones, so the time to recovery for each process will generally be much quicker.

      If you're barely using your memory, then ignore this advice. But if you're using a significant percentage of your memory, and you're using your system as a server, the probability is extremely high that you'd benefit from virtual memory.

      --
      You are not alone. This is not normal. None of this is normal.
    73. Re:Not much, anymore... by Alioth · · Score: 1

      Linux also has a "knob" to control how agressive it pages out bits of physical RAM - see /proc/sys/vm/swappiness . The values can be between 0 (try to never swap) and 100 (agressively move pages out of RAM to swap). The default is 60.

    74. Re:Not much, anymore... by Spackler · · Score: 4, Funny

      #echo [0-100] > /proc/sys/vm/swappiness

      I hope this is not your example of how Linux is ready for the mainstream.

    75. Re:Not much, anymore... by walt-sjc · · Score: 3, Informative

      But that's the ONLY way to fully answer the question.

      The old guideline of swap size = 2X RAM size still holds as RAM usage (application bloat) / system memory increases automatically mean swap space increases. But that was a general purpose guideline, and the guidance has ALWAYS been to set your swap space size to what you need based on actual usage. your only other option is to just set it to a ridiculously high number.

      If you are concerned about something yet are unwilling to spend 10 minutes educating yourself on how to deal with your concerns, then you have to live with the current situation or pay someone to handle your concerns for you. There is no magic bullet.

    76. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      If that's truly from an MCSE, and I have no reason to doubt it as it looks like something those paper tigers would say, I'd have to say that particular MCSE is a 'tard. First calling XP the ME of the 21st century...WTF?
       
      With drives being huge and cheap now, there's no reason not to have a swapfile that's more than you'll ever use. I suggest 3000MB for both min and max size, then run sysinternal's page defrag utility, making it one contiguous block. This not only is more than enough for damn near anyone, but it also will cut down in the instances of "page fault in non-paged area" errors that you'll see. What's more, if you're using more than 3000MB of virtual memory, you need more RAM in the first place.
       
      Oh, and to the people saying you should turn off virtual memory under Windows...don't, as that can cause programs to crash because they've been programmed to specifically swap out portions that are needed but not critical and if no virtual memory is present you get the crashy goodness that you really don't want.

    77. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      and if you want to create an & character use & exactly as you see it.

    78. Re:Not much, anymore... by walt-sjc · · Score: 1

      not all laptops have slow hard drives

      It's all relative. The best *current* laptop drive is still slower than a fairly low-end *current* desktop drive. A current laptop drive however is much faster than a high-end desktop drive from just a couple years ago however.

      If the laptop hard drive powers down, then it gets REALLY slow. :-) You really don't want to be swapping on a laptop or your battery life goes to shit. Note that the high-performance notebook drives are not so good for battery life in general - that's one of the big tradeoff's.

    79. Re:Not much, anymore... by Mattwolf7 · · Score: 1, Troll

      And you can do this in Windows?

      No you can't, but if you could it would be a registry hack

      Nice Troll...

    80. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      You sir, are an idiot. WinXP is not "just win2k with add-on crap". Rather, win2k is the winNT version of the 2000 windows family. Win2k does NOT have the same game performance and it does NOT support all DirectX features that WinXP does.
      Win2k is great, and so is WinXP.

      Btw, Vista is only in BETA and is already pretty darn stable (on most systems, not all) and its usability and organization is already much better than 2k or XP. And I found it to be easier and quicker to setup a simple ftp/web/php/mysql server using the new Vista IIS than it ever were on win2k / xp. Altho I didnt fully configure apache, basic setup also worked perfectly.

      So, I hope you actually understand something about OS's, but you certainly are pretty hard headed.

    81. Re:Not much, anymore... by GooberToo · · Score: 1

      Windows constantly pages because that's how the kernel works. Under windows, EVERYTHING is dynamically loaded via paging from the page file. Yes, that means it's initially loaded directly to the page file. They do this to back-store, on demand paging. The way Linux does it is to load from a shared lib on demand. To do this, they load from the shared lib, into the VMM, where it can later be written out to the page file. On windows, they directly load it to the page file, loading to the VMM as needed. I hate to say this, but the Window's solution actally has some advantages.

      Thusly, no matter what you do under Windows, the pagefile is heavily used. I highly recommend the use of sysinternels Page Defrag utility. Otherwise, your page file can become very fragmented. If you're a Windows user, check it out! It also helps defrag various system registries which is normally left untouched; which causes it suffer from heavy fragmentation too.

    82. Re:Not much, anymore... by walt-sjc · · Score: 2, Informative

      I know you're just trolling, but...

      Just because the kernel has this tuning feature does not mean everyone has to muck with it. Having the capability to tune / customize is what makes linux flexible enough to use on devices from watches to supercomputing clusters / mainframes. If you don't want to make your own Linux Myth PVR, get a Linux based TIVO that doesn't require any mucking around at all. Linux, the kernel, has been in the mainstream for YEARS.

    83. Re:Not much, anymore... by mathew7 · · Score: 1

      I didn't mean that "pagefile" comes from W95. My idea was that the "memory file" was called "swapfile" in Windows =3.11 and "pagefile" from W95. So I believe that MS has switched from a "whole application swap" to a page swap. I know that in WindowsXP you can swap only part of the application. I had experienced it even with firefox.
      I had contact only with MS-OSes (and compatible) and linux (1st time around '95) and only with x86. I really don't know how linux manages swapping, but I think the idea of swapping all-or-nothing is not good. I also think it (swapping as you describe it) exists for compatibility with processors which cannot work with pages (Windows 3.11 ran on 286, but Windows95 required 386).
      PS: about Win95 requiring a 386, I know it was because of virtual mode which 286 did not have, but there were many changes in the architecture and paging may be one of them. I'm really bad at hystory.

    84. Re:Not much, anymore... by Guysmiley777 · · Score: 1

      WinXP Pro: Luser. why are you running the Windows ME of the 21st century?

      Because I'm a gamer and some software these days unfortunately requires XP (Armored Core for BF2 for example). Do I like it? No. Am I using it? Yes.

      --
      Coding with assembly is like playing with Legos. Coding an application in assembly is like building a car with Legos.
    85. Re:Not much, anymore... by shaneh0 · · Score: 1

      FWIW, there's a registry setting for high-color/true-color in 2000 Server Terminal services. I'm not sure, but i think it's under HKLM > Sys > CurrCtrlSet > Term Server > WinStations. Something like that.

    86. Re:Not much, anymore... by InfiniteWisdom · · Score: 1

      Under Windows it seems it'll swap out whether the free RAM is needed or not
      Linux does this too (google swappiness), and it's a good thing. Having unused pages sitting around in RAM is a waste of memory. It makes sense to have some free pages around so that new memory allocation requests can be completed quickly. Think of it as a tradeoff between having inactive applications run efficiently vs currently running or newly launched applications running efficiently.

    87. Re:Not much, anymore... by astralbat · · Score: 3, Insightful
      This parameter was introduced with 2.6 and it's useful for laptops where a lower value will mean it swaps less. This parameter could be used for a distribution's event scripts that will change the value when, for example, the user unplugs their laptop from AC.

      The idea is the users's battery life is extended slightly without them realising how.

    88. Re:Not much, anymore... by astralbat · · Score: 1

      Mod parent up!

      People are missing the point here that a lot of physical memory is used for disk cache (pages of data from the disk drive accessed frequently) Just because you don't ever use more than your physical memory, doesn't mean to say you don't need any swap. Anything to prevent frequent read accesses to disk is a good thing!

    89. Re:Not much, anymore... by Daytona955i · · Score: 1

      d'oh... I need more sleep.

    90. Re:Not much, anymore... by Zan+Lynx · · Score: 1

      I run a 1 GB laptop and it hits swap all the time. You should try running Gentoo and compiling KDE with kdeenablefinal turned on. GCC will hit 800 MB, easily.

    91. Re:Not much, anymore... by hubie · · Score: 1

      To over-simplify, high resolution has nothing to do with the number of pixels, but with the size of the pixels. Take an image with 5-micron-sized pixels, even if it was 32x32 in size, and it would have better resolution than your 4000 dpi image (which works out roughly to have 6.35-micron-sized pixels).

      Ultimately of course, when you are talking about imaging systems, you need to factor in the resolution limit placed by the optics, not the sensor; it wouldn't make sense to use a sensor with 10-micron-sized pixels when your lens on the front is giving you a blur spot that was 100-microns wide. I am not familiar with scanners, so I can't say how they perform and what 4000 dpi really means, but I do work with other imaging systems. You can see some very high resolution systems with one megapixel cameras or less (from the folks that do microscopy, for instance).

      The consumer market gets all excited about the total number of pixels like they used to get with processor clock speed. There are many reasons most people don't need these very large arrays (such putting a crappy lens in front of it and losing your resolution), but it also never made sense to me the image sizes you get out the back. A 16M-pixel camera, with 24 bits per pixel gives a raw image size of 366 MB. To reasonably handle the images, the cameras compress the heck out of the image using a lossy algorithm (and thereby again lose image quality). In the end, at least in the consumer market, you're stuck with these larger and larger arrays because that is what they keep sticking into their newer models, so the sizes of the images we will take will just continue to grow.

    92. Re:Not much, anymore... by Anonymous Coward · · Score: 0
      WinXP Pro: Luser. why are you running the Windows ME of the 21st century? at least you aren't running WinXP home, though. just follow the guidelines for win2k, since that is all WinXP pro is, win2k with add-on crap, no changes to kernel or underlying function.
      So, what your telling me is that in the 5 million or so extra lines of code added to XP over 2000 (excluding SPs), ZERO of those were added to kernel code or the underlying functions of Windows. AND that ZERO existing lines were modified at all. You are one sad, naive person.

      I also want to hear your reasoning for referring to WinXP as the "Windows ME of the 21st century". The issues I see with WinXP as opposed to Win2k are COMPLETELY different than the issues WinME had as opposed to Win98. I dislike Windows as much as the next person but there really isn't a need to exaggerate their shortcomings. Can you say "hyperbole"?
    93. Re:Not much, anymore... by spyrochaete · · Score: 1

      From my research and experience your advice on WinXP is spot-on. The only thing I'd add is that the swap file itself can become fragmented (though not so much when you make min/max sizes the same) and the Windows GUI and commandline defragmenters don'don't touch that protected space. If you want to keep the swap file defragmented the only solution I know of is to use the excellent Diskeeper defragmenter. Diskeeper also tidies up the MFT (master file table) which can also speed up memory paging if the swap file is on the same drive as the OS or data.

      Finally, I would recommend putting the swap file on a separate physical drive than the system partition, or from disk-intensive applications like a database or game. However, WinXP becomes unstable if there is no page file on the system drive so you should create at least a 256MB file on C.

      This extensive and fantastically informative guide on tweaking virtual memory was a huge help and a fascinating read.

    94. Re:Not much, anymore... by Com2Kid · · Score: 1

      Try loading said image up into Photoshop.

      Run any kind of filter over it.

      Enjoy running out of memory!

    95. Re:Not much, anymore... by kyouteki · · Score: 1

      2GB is enough to store almost 7 days of UNCOMPRESSED cd quality digital audio: 2^31 bytes / (44,100 * 2) bytes per second

      What do you mean? Uncompressed CD audio is 80 minutes for 700MB. If you mean losslessly compressed...

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    96. Re:Not much, anymore... by Dave2+Wickham · · Score: 1

      I've encountered the Linux OOM killer a couple of times; I believe it was when Mozilla or Firefox was choking on a page when I was on a machine with about 128MB of RAM. It does exist. Or did at one point, at least.

    97. Re:Not much, anymore... by Vlijmen+Fileer · · Score: 0

      I take it you mean "The Win2K kernel kept the registry hives in the NON-paged pool"?

      You Wizard of kernel-lore... ;-)

    98. Re:Not much, anymore... by madcow_bg · · Score: 1

      >>Under Linux, you won't swap much anyway unless you need it.

      >Like if you're compiling OpenOffice.org ;)

      But what if I *am* compiling OpenOffice? I did, twice. The last time I had Java, so actually it compiled all of the class files. It took 2.5 days, on my 1.7 Pentium 4 M. The magic of Gentoo...

      The main problem was not the swap, but disk space - the compilation folder grew to over 3 GBs!!! I had to mount the compilation directory on my storage, because my Gentoo partition was far from enough for this monster. Still, it was fun!

    99. Re:Not much, anymore... by chrish · · Score: 1

      Yup.

      OS9 had sucktastic memory management; unless it changed radically from OS7, etc. you were still stuck with specifying memory partition sizes per application (a detail end-users should NEVER have to deal with... can you hear me yet, Java?). The virtual memory there attempted to swap inactive code out to disk (much like on a real VM system)... but there's a problem with that. Many old Mac apps busy-wait on an event loop, and they trigger every now and then on a timer, even if they're not really doing anything. So if you run out of real memory, you're still boned, and you could run out of memory even when you had "free" memory because you tried to run an app that was bigger than the largest hunk of free memory.

      OS X has a proper virtual memory system. You don't have to worry about telling the OS how much memory an application will use (the app does that by requesting memory). Inactive pages (8k blocks? not sure, and too lazy to look it up right now) an be swapped out as needed to disk, and there's no memory fragmentation... the kernel maps physical memory so it appears as a single contiguous chunk to the application. You're still not happy when you run out of physical memory and things start swapping to/from disk, but at least the OS can continue to run until things settle down again. Unless some bozo program stops repsonding to events and you're stuck looking at that damn rainbow beachball...

      I summary... old versions of MacOS have an old-school memory model based on the good ol' days before microcomputer CPUs had support for memory protection. Mac OS X makes proper use of memory management units and other fancy bits supported by modern CPUs. OS X is good sauce.

      [Note that I might have some of the details wrong, I never used OS9.]

      --
      - chrish
    100. Re:Not much, anymore... by postmortem · · Score: 1

      PF usage in task manager still shows that page file is being used. So does the dxdiag.

    101. Re:Not much, anymore... by Anonymous Coward · · Score: 0

      I work under a mainframe OS and before VM was introduced (20 years ago?) the OS would happily swap processes or unused parts of processes out, it would kill any process which tried to allocate more memory than was physically available.


      Well, I was using VM (paging, not swapping) on Atlas in the early 60s: slightly more than 20 years ;-)
    102. Re:Not much, anymore... by uarch · · Score: 1
      If you have =/> 2GB RAM, disable swap, unless you are running server, in which case 4GB is the magic number. The 2 drive swap method just doesn't seem to work as well on Win2k as it did on WinNT; no clue why, but i've tested it repeatedly.
      Turn off swap on a server? Are you SURE you want to do that? That sounds like a very bad idea unless you know for a fact that you're seriously under utilizing the machine.

      Some of the jobs I've started at work use over 4G just for a single process. (Thankfully it was running on a 32 processor Regatta with 256GB of RAM)
    103. Re:Not much, anymore... by Anonymous Coward · · Score: 0
      WinXP Pro: Luser. why are you running the Windows ME of the 21st century? at least you aren't running WinXP home, though. just follow the guidelines for win2k, since that is all WinXP pro is, win2k with add-on crap, no changes to kernel or underlying function.


      Because Microsoft stopped support for 2k in December.

      But other than that...

      Don't give a different min and max size use a static paging file or it becomes fragment faster, having a huge impact on performance. It't also a good practice (tho not always possible) to have the paging file on a different physical drive to the OS. If you are running something memory intensive like a ps4 licence server set the paging file to 4GB static and watch that baby fly.

      The generalisations above (and the one I just made) are just that good for a starting point but servers are used differently different roles require different resources and what works for one might not work for another. You should establish a performance baseline and work out from there your optimum page file size. Hint - Read up on performance monitor

    104. Re:Not much, anymore... by dark_knight_ita · · Score: 1

      As I did, too :P OOo 2.0.3 needed ~8 hours to compile on my 1.6 Centrino Laptop... he used something like 5 GB of temporary disk space and 1+ Gb of overall memory (pyhisical + swap). Luckly I have 1Gb of RAM + 512 Mb swap, so I (my laptop, to be precise :) ) made it ;)

    105. Re:Not much, anymore... by Fulcrum+of+Evil · · Score: 1

      True enough. In the place I work at, swap is generally not very useful compared to more memory or another machine, so being able to have 1TB swap isn't really helpful. I guess photo edittors might be different.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    106. Re:Not much, anymore... by makomk · · Score: 1

      Hmmm, I wonder...

      IIRC, even if you've got no page file whatsoever, Windows can and does still swap out application code (since it can just read it back in from the executable when it needs it). Could that be the reason for the odd figures?

    107. Re:Not much, anymore... by makomk · · Score: 1

      I suspect you probably don't want to know about Windows 3.x swapfiles (I certainly don't). IIRC, the Windows 3.x API had some interesting design in that area (for example, for best performance you were supposed to keep a handle to large allocations and only actually request a pointer when you needed it, since some early versions of Windows could swap out chunks of memory and then have to swap them back in at different addresses). Fortunately, I never had to deal with any of it, and so I really don't care...

    108. Re:Not much, anymore... by makomk · · Score: 1

      The Linux OOM killer is real. Unfortunately, it behaves really, really stupidly when a long-running task with lots of accumulated CPU time suddenly starts gobbling up all available memory. For example, recently Konqueror started gobbling up memory (due to a bug in the PDF viewer, as far as I could tell). Since I leave my PC running continuously with it open, and it's not exactly light on the CPU, it had accumulated lots and lots of CPU time - so instead of killing it, the OOM killer went for (in rough order) Azureus, my window manager, my IRC client (X-Chat 2) and my shell window (Konsole). I eventually managed to manually kill the rogue task, but in previous cases with other programs the address space limit seemed to get there first (and I only have 1Gb of RAM and about the same in swap, so that's impressive).

      Still, at least it's well-commented ("this algorithm has been meticulously tuned to meet the principle of least surprise" - snort!)

    109. Re:Not much, anymore... by Anonymous Coward · · Score: 0
      Remote desktop/remote assistance. That's XP's killer feature. Unless you've got 2K server you don't get that, and even then you only get 256 colours remotely.

      Sorry, but I disagree. In XP Home, remote assistance is an open invite to become part of a botnet. In a large business setting it is useless since there is already a dedicated helpdesk staff (well at least in this Fortune 100 company...) who can access your computer without it. I disable remote assistance whenver I come across it.

      For home users there's fast user switching. You can't get that on 2K. And XP SP2 added much security goodness you shouldn't be without.

      Except for a very few savvy users, no one I've observed has ever made intelligent use of fast switching (if at all). Interestingly, the one person I've observed using it the most was a long time Mac user using it on Xandros Linux 3.0.

      And... what possible XP SP2 security goodness are you talking about? Don't say XP built-in firewall or security center in the same breath. You'll be laughed out of the building. Genuine Advantage??? ROTFLMA
    110. Re:Not much, anymore... by hackstraw · · Score: 1

      #echo [0-100] > /proc/sys/vm/swappiness

      I hope this is not your example of how Linux is ready for the mainstream.


      No, this is:

      for i in `seq -f 'node%04.0f' 1 2048`
      do
          rsh $i 'echo 100 > /proc/sys/vm/swappiness'
      done


      Granted its a cheesy example, but I would rather do that on 2,000+ Linux machines vs playing around with a registry key on 2,000+ Windows machines any day.

    111. Re:Not much, anymore... by DrVomact · · Score: 1

      So how about being "informative" and telling us what the rules for XP are?

      --
      Great men are almost always bad men--Lord Acton's Corollary
    112. Re:Not much, anymore... by jamiethehutt · · Score: 1

      This parameter was introduced with 2.6 and it's useful for laptops where a lower value will mean it swaps less. This parameter could be used for a distribution's event scripts that will change the value when, for example, the user unplugs their laptop from AC.

      The idea is the users's battery life is extended slightly without them realising how.


      It's used so you can tune how much RAM is used for running applications and how much is used for caches. If your running a server you probably dont want an unused program taking up your ram, so set the swappiness high (70) and have the system swap it out leaving more RAM to cache information from the disk. If your running a desktop however you want to keep your applications in RAM so you can quickly switch between them and keep them responsive, so set your swappiness low (30).

      Nothing about battery life, all about plain old performance. ;-)

    113. Re:Not much, anymore... by kgwilliam · · Score: 1
      To correct a few things...

      Win2k: if you have less than or equal to 512MB, set min to 1.5 times RAM, max to 2 times RAM. if you have greater than 512mb, set swap min/max to 1.5 times RAM. If you ever get an "out of virtual memory" error, defrag and add 100mb to min/max. If you have =/> 2GB RAM, disable swap, unless you are running server, in which case 4GB is the magic number.
      Try reading http://www.microsoft.com/technet/prodtechnol/windo ws2000serv/reskit/core/fnec_evl_wafw.mspx?mfr=true . Basically, disabling the paging file or coming up with a 4GB magic number isn't based on any real evidence and is not very good advice.

      The 2 drive swap method just doesn't seem to work as well on Win2k as it did on WinNT; no clue why, but i've tested it repeatedly.
      Perhaps you need better testing methodologies. This works the same on Win2K as it did on WinNT.

      WinXP Pro: Luser. why are you running the Windows ME of the 21st century? at least you aren't running WinXP home, though. just follow the guidelines for win2k, since that is all WinXP pro is, win2k with add-on crap, no changes to kernel or underlying function.
      1. "at least you aren't running WinXP home, though." - And why would running WinXP home be any different for 99% of home users? If you are confused about the difference between Pro and Home you should read http://www.winsupersite.com/showcase/windowsxp_hom e_pro.asp. Basically WinXP Home does 100% of what home users need. Pro is in almost all cases only needed in a networked environment (a network other than a home network).
      2. "since that is all WinXP pro is, win2k with add-on crap, no changes to kernel or underlying function." - Not sure where you got this information. Perhaps http://msdn.microsoft.com/msdnmag/issues/01/12/XPK ernel/ will enlighten you as to the differences between the 2 OSes.

      Win2003: No clue. Vista: Not only have no clue, but I promise you I never will.
      Fair enough. Perhaps we can get the True Word from an MCSE who's learning curve has gone past NT4...

      In general you should use the techniques from the Technet article in my first link to tune your paging file according to your system's memory usage.
    114. Re:Not much, anymore... by shaitand · · Score: 1

      It is about priority. The additions to XP are changes in eyecandy, multimedia, and of course drivers. Actual security changes have been backported to 2k of course. If you don't care about your computer being pretty or aren't a gamer then the XP specific changes are just a load of bloat.

    115. Re:Not much, anymore... by astralbat · · Score: 1
      Nothing about battery life, all about plain old performance. ;-)
      Yes, this is right. But you should think about the disk activity going on when you set swappiness high and when you set swappiness low. Setting it higher means increased disk activity.
      I suppose it depends on what the user is doing, but at the end of the day, swappiness DOES have an impact on battery performance when the disk has to be spun up just to do some swapping and perhaps the default of 60 is a little too high.

      A bigger impact on battery performance though would be the /proc/sys/vm/laptop_mode parameter (off by default). Setting this can mean the disk doesn't spin up so often to flush dirty buffers.
    116. Re:Not much, anymore... by iangoldby · · Score: 1
      Monitor your own resource usage and figure out what YOU require.

      That on the face of it sounds like good advice, but the problem is that most people who are asking that question are just about to install a new operating system and want to know how to partition up their disk. It is catch 22 - you need to know how big to make that swap partition before installing the OS, but you can't figure out how big you need it until you have installed and run the OS. Once you've installed the OS and started using it, you can't change the size of the swap partition without major trauma. (Or you can use a swap file instead, but if you were prepared to settle for the inefficiencies of a swap file, you probably wouldn't be bothered if it wasn't the optimum size anyway!)

      The only solution appears to be to install the OS twice, the first time with your best guess, then once you've figured out how much swap you really need, wipe the disk and start again. But most people would rather live with a sub-optimal swap partition than go through all that partition and install process a second time.

      So the original question still stands. For those that don't want to faf around doing multiple installs, what is a good rule of thumb for the swap partition size?
    117. Re:Not much, anymore... by tomservo84 · · Score: 1

      2GB is enough to store almost 7 days of UNCOMPRESSED cd quality digital audio: 2^31 bytes / (44,100 * 2) bytes per second...

      Really?? Hmm...then how come when I digitize audio at 44.1k...I get only 4 HOURS of uncompressed audio in that space?!?!?! Methinks you are not right.

      --
      Agile Spaceport - You will never find a more wretched hive of scrum and villainy. We must be cautious.
    118. Re:Not much, anymore... by gameforge · · Score: 1

      Yeah, I was super tired last night (as you can see from the mess I made out of less than and greater than signs in another post in this thread. You're absolutely right.

      Still, recording four hours of audio without any compression lag and NO THRASHING. That's pretty good.

    119. Re:Not much, anymore... by photoshack.com · · Score: 1

      I have the *best effing pc* available from Alienware. TWO dual core Zeons (1.6ghz per coreX4) and 4gb of ram. Fancy video card, fast system drive, raid 1 mirrored work drives...all this to run photoshop which needs to render 300mb (to start) files (which with history, layers, etc. winds up being 1.75 gb of ram and then it swaps.) Naturally, XP professional is 32bit, and can't handle more than 3.25gb RAM. So, even if it peaks the memory (which it does) then I still have to swap. Oh, and if I have outlook, a RAW conversion batch running, or anything else it's over the top. This system is still anemic for what I am trying to do- I guess I need a 5gb pagefile but it still sucks. It's why Mac people can give us crap...they don't seem to have these problems with Photoshop....sigh.

      --
      vin
    120. Re:Not much, anymore... by gameforge · · Score: 1

      Nah - Vista will be the true Windows ME of the 21st century. XP Pro is the patched version of 2K

      Yeah, it certainly seems to be a tradition for MS to repackage their own garbage with different colors.

      Vista will be to (every current version of 32-bit Windows, back to NT 4.0 before Win95) as Windows NT 4.0 was to 16-bit Windows. Windows Server 2003 is a closer relative of Windows NT 4.0 than it is of Vista; they're rewriting many parts of Windows that haven't been rewritten since NT4/Win95 (revised, yes; redesigned, no).

      The accelerated 3D interface is just a cute touch.

      Oh, and please remember, I never said that Windows Vista will do any of the following:

            1) Not suck
            2) Work correctly (or 1/2 correctly even)
            3) Be successful
            4) Not put MS' future at risk if it fails
            5) Ever be stable ...but if you can get your hands on a beta, it actually looks somewhat promising.

      All I'm saying is that it's NOT just a madeover XP.

      Side reading: Wikipedia's article on the "Availability Heuristic"

    121. Re:Not much, anymore... by gameforge · · Score: 1

      Get a motherboard that supports PAE and like 32GB of physical RAM.

      Or, hit up eBay and grab a modern SGI workstation of your choice.

      Most Mac's are going to chug on whatever you're doing too; unless you spend money on physical RAM (a LOT of money). You could do that as well.

      Alienware PC's are the spawn of video games, not graphic artists. I'll bet that little sweetheart rips Far Cry a new one...

    122. Re:Not much, anymore... by qazsedcft · · Score: 1

      PF usage in task manager still shows that page file is being used. So does the dxdiag.

      Page faults still occur by design. Windows has a late commit allocation scheme where the fault handler allocates actual physical pages the first time the program tries to access the memory. A "page fault" doesn't mean that any pages are actually loaded from the page file.

      What dxdiag shows is really the amount of memory from paged and non-paged pools. The paged pool is the memory that can be swaped to the page file. The non-paged pool is the memory that is guaranteed to be mapped to physical memory at all times.

      Finally, if you want to convince yourself that Windows really doesn't use a page file, just look in the root directory of your system drive. The page file is a file called "pagefile.sys". When you disable the page file and reboot you'll see that the file gets deleted.

    123. Re:Not much, anymore... by Vlad_the_Inhaler · · Score: 1

      How would a '4 Lancashire men' sketch run? Atlas *was* in Manchester? Or was it at Didcot?

      --
      Mielipiteet omiani - Opinions personal, facts suspect.
    124. Re:Not much, anymore... by paganizer · · Score: 1

      Nothing will run on XP (except the 64-bit kernel stuff that MS killed; I would trade my left nut for the ia64 patch they killed) that Win2k will not run better, including games. What they have done is include lock-outs in the installers that prevent the games from installing on anything but XP+.
      If you doubt this, create a text file, something on the lines of "I need a Win2k patch for XP only Armored Core.txt" and share it on a p2p network such as eMule; I doubt you will have to wait more than 2 days or so before you will get you Win2k enabling patch.
      I first noticed this with Age of Empires III, wouldn't let me install. I fixed that one myself, but quite a few others are doing it now.
      Long Live the XP Resistance!
      Guysmiley777, contact me by e-mail if you wish further concrete details.

      --
      Why, yes, I AM a Pagan Libertarian.
    125. Re:Not much, anymore... by paganizer · · Score: 1

      I would send you a copy of my resume, but I doubt you would believe it. MCSE was at the end of my career, i'm retired.
      I also was pretty sure that i mentioned everyone had a different opinion, and this was mine; I did not, unfortunately, use those exact words but that was the gist.
      Ok. Some programs REQUIRE virtual memory, they are written that way. In WIn2k+, the memory manager wants to be able to address out to 1.5 times the amount of RAM in your system.
      The goal is to avoid anything getting written to swap; it slows your overall system performance.
      If you can disable your swap, and nothing crashes, you don't get any request for more virtual memory, in other words if things just work better, then leave things that way... just do not forget that you did it.
      However, since the modern era sprang upon us, with SATA drives, and machines having a min of 512MB RAM, it is really not that much of an issue in the first place; so what if your computer writes some currently unused bit of code to swap? you are unlikely to notice.
      The only place is does matter is with people running legacy hardware, or really pushing the envelope with multiple tasks on modern hardware.
      One thing that some people do in situations like this (since NT 4+) is to mess with DisablePagingExecutive in registry; this keeps the NT executive from being paged to disk, making for a overall more nimble system.
      Oh, and I stand by the XP is the ME of the 21st century thing. integrated spyware/DRM? having to call MS when you add RAM? Enforced Validation to keep your machine from being a security risk to the world, even though the validation system is knowen to be screwed up? AMT technology, allowing your computer to be completely fried by MS at their whim, or the first hacker that figures it out?
      It is stuff like this that is making me move back to Unix/Linix; when I can't use win2k anymore, I won't be using a Microsoft product anymore.

      --
      Why, yes, I AM a Pagan Libertarian.
  3. Depends by beavis88 · · Score: 4, Interesting

    My rule of thumb these days is 1.5x RAM, unless you're at 2GB, in which case I go with 2GB swap as well. This is for *gasp* Windows, though.

    1. Re:Depends by ColaMan · · Score: 1
      From my MythTV box, which has a few other misc processes running:


      top - 11:50:40 up 4 days, 15:14, 2 users, load average: 0.05, 0.01, 0.00
      Tasks: 76 total, 1 running, 75 sleeping, 0 stopped, 0 zombie
      Cpu(s): 5.9% user, 0.6% system, 4.0% nice, 88.5% idle, 1.0% IO-wait
      Mem: 483476k total, 463240k used, 20236k free, 1804k buffers
      Swap: 899632k total, 232k used, 899400k free, 275920k cached


      Hmmm. Guess I don't really need swap after all.
      --

      You are in a twisty maze of processor lines, all alike.
      There is a lot of hype here.
    2. Re:Depends by Malc · · Score: 1

      I have 2GB of memory. I have my swap set at 768-1536 MB. I thought I'd set it lower than that... could Windows have increased the min. value permanently when it needed to increase? Whatever the case, I do not want 2-3GB of swap space. That means for my usage that I've got a problem. I find that when you're using as much swap as real memory that Windows starts to grind. Even after freeing memory, just bringing up the start menu can cause it to thrash the hard drive. So I'm realistic and keep my swap space to a size that makes sense. Why waste disk space on something I'm not going to use? Until recently, as far as I'm concerned, swap space is only there for emergencies. These days though I often hit 2.5GB usage (VMWare, some big JVMs, Photoshop, etc).

    3. Re:Depends by benplaut · · Score: 1

      I have 768, and i use a gig of swap. 1.5 is a pretty good amount these days, as you really don't fill up your ram all that easily. It's good as a backup, or when a process goes awry

    4. Re:Depends by th173 · · Score: 1

      I use the ck patch series for my thinkpad kernel. From the FAQ of the page I have the following information, which seems to come from a kernel developer and was alway enough for me, also on productive servers out in the wild.

      http://members.optusnet.com.au/ckolivas/kernel/
      How much swapspace should I allocate?
      Unfortunately there is not much good documentation on swapspace that is meaningful on today's hardware. As the discrepancy between ram speed and hard drive speed becomes greater each year, the old rule of 2*ramsize is just plain wrong. This was in the old days because the addr space was directly mapped into the first half of the double RAM sized swap, giving an easy translation formula; only the space >> RAM size was usuable as additional space.

      --
      There's never enough time to do all the nothing you want. --Calvin
    5. Re:Depends by Anonymous Coward · · Score: 0

      2 GB?!! That is sheer nonsense. Everyone knows 640k should be enough.

    6. Re:Depends by th173 · · Score: 1

      Missing text:

      Since most of your ram will be filled with cache, you don't need a huge swapspace, just enough to cope with transient periods of pressure.

      The size should actually depend on the speed of your hard drive. On current drives I recommend about 256MB of swapspace (no matter how much ram you have). You could double it for a striped raid0 array of swapspace.

      --
      There's never enough time to do all the nothing you want. --Calvin
  4. If you have enough, none by bob+whoops · · Score: 4, Insightful

    Back when I had 512MB of memory, I had a 512MB swap partition, but I noticed that I never came close to using all of it.

    When I got my new machine with 1G, I never bothered to make one at all, and I've never had a problem with it. If I do ever find myself in a situation where I need some swap space, I could always just create a swap file. It's a lot more convinient because it wouldn't have to be a fixed size, doesn't take up space when I don't need it, and I have one less partition

    Especially if you have 2G or more, I don't see a real reason to use swap

    1. Re:If you have enough, none by MyDixieWrecked · · Score: 5, Interesting

      not creating a swap partition at all is a bad idea, imo...

      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.

      I typically just make a 1 or 2 GB swap partition since I've got more than enough space to spare. I mean, back in the days when 128MB of RAM was considered a lot, and a 5GB drive was considered huge, no one would consider using 20% of their storage space for swap. Now, it's not unusual to have 300GB of storage, so what's 1% of that being used for swap?

      I've also got a serious collection of 2-6GB harddrives kicking around, now, so I've been using them for swap. It's really pointless to have a 4GB partition for data, so I just use the entire 6GB drive for swap on some machines.

      my primary server right now has a 4GB swap partition and 1.25GB of RAM... a piece of bad AJAX code that ran overnight wound up using all the RAM and had some seriously detrimental effects on the performance of the server. it took 25 minutes to ssh in in the morning and when I finally got in, I found that the load averages were at over 100 (I've NEVER see that before).

      my point is that even if you have a LOT of RAM, it's still handy to have some spillover available.

      --



      ...spike
      Ewwwwww, coconut...
    2. Re:If you have enough, none by edmudama · · Score: 5, Interesting

      If you've got a 300GB primary drive, it's foolish to use a 5GB drive for your swap. While you gain the benefit of having that drive separate from the primary (and potentially not contending for the bus), those drives are so far apart technology wise that you'd probably be better off with a swap partition on your most modern disk.

      That 2/5/6GB drive may have a 20MB/s sequential rate at OD and half that at ID. Modern drives more than double that sequential performance (or triple), which is what's critical when swapping in/out a large job. Many drives in that generation don't support UDMA either, and talk with PIO, meaning you get no data checksum on your transfers.

      You can span generations when you're using a cost reduced modern drive (fewer heads, same formats) but the drive that was stretching to make 5GB across 6/8 heads will be a real POS compared to modern drives performance wise.

      Thrashing is bad, but thrashing to a slow disk I'd think would be worse. It is even compounded since that 5GB drive is probably PATA, meaning you're going to have your swap drive and primary drive sharing a cable, which will basically nuke most of the savings of 2 disks since they'll be reselecting master/slave at almost every command.

      --
      More data, damnit!
    3. Re:If you have enough, none by gfxguy · · Score: 4, Insightful

      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.

      Frankly, while I do use swap, in this case I'd rather have the process crash sooner rather than later.

      --
      Stupid sexy Flanders.
    4. Re:If you have enough, none by Anonymous Coward · · Score: 0

      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.

      That's why I like per-process ram limits - even if it goes bezerk it won't bring the system to a crawl.

    5. Re:If you have enough, none by EvanED · · Score: 4, Insightful

      Well, again, that depends; if your usage patterns don't cause enough memory use to justify swapping, and you're just creating a swap partition for the emergency where some program decides to break, then it hardly matters if your swap drives are slow, because they are never accessed.

    6. Re:If you have enough, none by hackstraw · · Score: 2, Insightful

      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.

      Personally, I prefer a runaway process to run out of resources and stop vs take over my whole system. It takes a long time to page out 1+ Gigs of RAM. It takes a long time to unpage all of that at shutdown or even when an app is closed.

      Swap completely depends on the computer's real RAM available and the purpose of the computer and the OS on said computer.

      To adequately answer the question, "How much Virtual Memory is Enough?" The correct answer is "It depends".

      Having too much swap on a HPC type of machine is a nightmare and will kill performance. Having too little swap on a general purpose server (moreso real RAM) is going to hurt performance. Paging out too much on a laptop with a slow disk can be very painful and slow down the shutdown process.

      There is no right answer.

    7. Re:If you have enough, none by Anonymous Coward · · Score: 0

      If you have a runaway process, then all you have bought is a bit of time. It will still hit a wall and your system will be incredibly slow (i.e. difficult to recover from).
       
      The real answer is if you need swap for NORMAL running, then have it. If you are not swapping under NORMAL condition, then turn it off.

    8. Re:If you have enough, none by Anonymous Coward · · Score: 0

      that doesn't make any sense.

      if you have a runaway program eating memory, it will also eat all your swap

      and if it doesn't you have just wasted a ton of disk space for no reason.

      so, in short what you say makes no sense.

    9. Re:If you have enough, none by MyDixieWrecked · · Score: 1

      well, machines of mine that have a 300GB drive don't have the smaller drives (10GB) in them. my point was really that when you've got 300GB of storage, does the difference between 500MB and 5GB of swap really matter? why not just go with the latter?

      however, in response to your mention of the fact that older drives will be slower... you're right. I just use those drives in machines because I really dont' know what else to do with them. I threw out all of my 1GB drives a couple years ago and now I've got piles of 4-8GB high performance (as of like 1999) scsi harddrives kicking around that I don't know what else to do with.

      --



      ...spike
      Ewwwwww, coconut...
    10. Re:If you have enough, none by MistChild · · Score: 1

      Actually, having swap on a huge drive, if it is the only available drive will have wonderful results in contention if you have pre-emptive paging and swapping going on. A slower swap drive, used infrequently, is fine and you don't contend with data by seek-thrashing the 300GB drive.

      I tend to put the page/swap file (for Linux) on the otherwise least used drive. With 1GB of memory, 30% to the file buffering I have on occasion paged, actively. Then again, large builds while playing in Gimp with several pictures can cause occasional overflow of the lower 700MB. But because of the setup, I never notice it in the activity as the CPU has the horsepower to keep busy and do the build in the background. If I just run the build, and don't run something fat othewise, little to no swap-in happens and the build runs the same amount of time (well, within 10 seconds) on the wall.

      99.44% of the time, the system doesn't swap. With paging not contending with the data being diddled, and enough file share that temp files never see a disk, the system flies even in the .66% of the time I page/swap some.

      (Right now I have a 10GB swap because that is how big the odd drive is).

    11. Re:If you have enough, none by Anonymous Coward · · Score: 0

      it gives you more time.

    12. Re:If you have enough, none by MyDixieWrecked · · Score: 2, Insightful

      Swap completely depends on the computer's real RAM available and the purpose of the computer and the OS on said computer.

      To adequately answer the question, "How much Virtual Memory is Enough?" The correct answer is "It depends".


      exactly... and some OSs (read: OSX) caches less-frequently used data (cached window contents, and other images, etc) to the drive to free up real RAM; it doesn't matter how much RAM is installed on the machine, it'll still use the swap. Even my machine at work with 8GB of RAM frequently uses the swap even before 1/4 of the RAM has been touched.

      --



      ...spike
      Ewwwwww, coconut...
    13. Re:If you have enough, none by fuzz6y · · Score: 4, Interesting
      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.
      You never know when some runaway process is going to eat all yer RAM and swap combined, no matter how much swapspace you've got.
      a piece of bad AJAX code that ran overnight wound up using all the RAM and had some seriously detrimental effects on the performance of the server
      too bad you had all that swapspace for it to run rabid across. if you'd had no swap at all, 1 of 2 things would have happened:
      1. the kernel kills the process because of a low memory condition
      2. an attempt to allocate memory fails. The application then handles this somehow. Since we've established that it's a lousy application, I'd guess it handles it by crashing.
      Either way, the Dude^W server abides.
      Naturally if you actually had that much physical RAM, the process would have still gone nuts, but your server wouldn't have had to thrash its disk for every process except the prodigal son, so the performance hit probably wouldn't have been noticeable.
      --
      If you're going to be elitist, it would help to be elite.
    14. Re:If you have enough, none by WuphonsReach · · Score: 2, Informative

      About the only thing I'd use them for is a PostgreSQL xlog location (the scratch area that PostgreSQL writes to prior to committing the writes to the database). It's all sequential writes, not very high volume, but when the xlog is on the same spindle as the database you get a lot of contention and slowdown in write-heavy applications.

      Even then, I'd probably replace the 5GB drive with a more modern 300GB or 400GB spindle. Create 5GB for the swap area on it, use the rest for temp directories, the xlog, and a quick-n-dirty backup location for rsync snapshots.

      (Older drives are *really* slow... 5-10MB/s vs 30+ MB/s for a more modern drive. The 750GB drives do 75MB/s at the outer diameter.)

      --
      Wolde you bothe eate your cake, and have your cake?
    15. Re:If you have enough, none by RhettLivingston · · Score: 2, Interesting

      "you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got."

      If you truly have a runaway process, it will use up all of your swap, no matter how much swap you've got. In most cases, it would be better for it to die sooner rather than later.

      I am a very heavy user and run many applications simultaneously. I have been running XP with 1 or 2GB of RAM and no swap file for over a year now. Despite having dozens of tabs open in two different browsers and running programs like Studio 10 for movie editing, I've never come close to running out of RAM.

      Interestingly, it seems that Windows programs in general use less RAM if they have less virtual memory available to them. I have experimented with this to prove it to myself by reloading two identical 2GB machines with identical OS and software loads, setting one to have a 5GB swap and the other to have no swap, and starting up the same dozen or so applications on each. The "commit charge" on the machine without the swap was over 200MBs lower than on the one with swap.

    16. Re:If you have enough, none by MikShapi · · Score: 2, Interesting

      But how does swap help?

      If you have 2GB of RAM and a process started leaking violently, providing it with 1.5 gigs of (physical) ram to work before it or the box dies or 3.5 gigs of ram (2 of which are swap) is meaningless. If it'll be chugging so much memory, it's probbably leaking without restraint anyway.

      This really depends on how likely you see a scenario where you'll be (legitimately) using more than your physical 2GB. For my office desktop box, that's a "never ever ever, not by a long shot", so I plain don't need the swap. Were I running a 512MB box with 1GB of ram I'd be fine. 2 gigs of real ram? when and how the hell would I be using that swap?

      Of course, if I were running software that'd be using up 1.8GB on average, say some game with a chubby 3D engine, it'd be a whole different ballgame.

      As always, depends on your personal needs.

      --
      -
    17. Re:If you have enough, none by geminidomino · · Score: 1

      We need a "+1, Big Lebowski" mod option.

    18. Re:If you have enough, none by Jeremi · · Score: 2, Insightful
      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.


      The thing is, in that situation, swap just makes things worse. Now instead of having a computer with all its RAM used up, you have a computer with all its RAM and all its swap space being used up, and it's slow as molasses due to constantly waiting for the hard disk I/O.


      At least without swap, the runaway process will be killed in a few seconds and then you can continue working.

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    19. Re:If you have enough, none by An+Audience+of+One · · Score: 1
      my primary server right now has a 4GB swap partition and 1.25GB of RAM... a piece of bad AJAX code that ran overnight wound up using all the RAM and had some seriously detrimental effects on the performance of the server. it took 25 minutes to ssh in in the morning and when I finally got in, I found that the load averages were at over 100 (I've NEVER see that before).

      OTOH, would it not have been better to let memory fill up and the OOM killer kill your AJAX code? Rather than stopping your server from responding overnight. I've seen machines requiring console access or a forced reboot to recover from that.

      We have several servers where the reduced responsiveness of hitting swap is as bad as them going away, we'd rather make sure that the only time it can run out of memory is with a rogue process and hope the OOM killer reaps it first.

    20. Re:If you have enough, none by Duncan3 · · Score: 1

      2GB of DRAM here, swap disabled.

      Never had a problem, and all swap can do is slow you down.

      .

      --
      - Adam L. Beberg - The Cosm Project - http://www.mithral.com/
    21. Re:If you have enough, none by ookaze · · Score: 1

      What you say is plain wrong.

      What counts with your drives is not sequential rate at all. Access time is what counts.
      I use a very old 4 GB SCSI drive as swap (half of it is swap, I have 1 GB of memory). I tried to use swap on my latest SATA drive, and the system instantly felt more sluggish. The old SCSI drive just trounces the SATA drive, and I'm sure the sequential rate of the SATA drive is far higher, but the access time of the old SCSI drive is far better : I just don't notice it when it's swapping !

      And what's this BS about swapping in/out a large job ? What kind of large job would you use on a PC with PATA disks ? J2EE jobs ? Huge Mono jobs ? I have a hard time seeing the need for 20 MB/s sequential rate even if your data was sequentially written in your swap file, which I'm sure they aren't. Anyway, like I said, my very old SCSI drive do better than the latest SATA drives, except perhaps Raptors, which I haven't tested, but they have a better access time than ordinary SATA drives.

    22. Re:If you have enough, none by Nutria · · Score: 1
      I typically just make a 1 or 2 GB swap partition since I've got more than enough space to spare

      On big disks, swap files seem more flexible to me, since otherwise you are wasting a partition on sub-1% of total disk space.

      Another thing I do is create "spare" swapfiles, and if the existing swap is getting too tight, I can quickly add another gig of vm.

      Why not enable all of them all the time? Because I think that the 2.6 kernel does not like high swap:RAM ratios.

      I just use the entire 6GB drive for swap on some machines.

      By using such old/slow disks, you're chopping performance even more.

      Instead of a slow 6GB swap disk, use 2.5% of your 200GB drive for swap files, and now you have an available slot for another modern hard drive.

      --
      "I don't know, therefore Aliens" Wafflebox1
    23. Re:If you have enough, none by Ed_1024 · · Score: 1

      Maybe modern OSs in their default state have become too permissive in terms of resource allocation? One process really shouldn't be allowed to bring the whole system to its knees in terms of swapping; what happened to "No, you CAN'T have any more memory - you've got far too much as it is..."

      It rather defeats the object of a multi-tasking OS if one task can effectively bring everything to a standstill.

    24. Re:If you have enough, none by HawkingMattress · · Score: 1

      I've also got a serious collection of 2-6GB harddrives kicking around, now, so I've been using them for swap. It's really pointless to have a 4GB partition for data, so I just use the entire 6GB drive for swap on some machines.

      But those disks must be way slower than your main, newer disks. And since swap is often used by the vm in other cases that just running out of ram, it probably slows your system down because of very slow I/O.

    25. Re:If you have enough, none by Guysmiley777 · · Score: 1

      I've also got a serious collection of 2-6GB harddrives kicking around, now, so I've been using them for swap. It's really pointless to have a 4GB partition for data, so I just use the entire 6GB drive for swap on some machines.

      One problem I see with that is those old hard drives are as slow as molasses in January, both in access time and throughput compared to a modern drive. So if you do end up swapping you're punishing yourself even more.

      --
      Coding with assembly is like playing with Legos. Coding an application in assembly is like building a car with Legos.
    26. Re:If you have enough, none by poot_rootbeer · · Score: 1

      you never know when some runaway process is going to eat all yer RAM and need to use swap... no matter how much RAM you've got.

      You're just delaying the inevitable. Eventually that runaway process is going to eat all yer physical RAM and all yer swap space, and then what happens?

    27. Re:If you have enough, none by ultranova · · Score: 1

      If you truly have a runaway process, it will use up all of your swap, no matter how much swap you've got.

      Not true. I have 1 gig of physical memory, 5 gigs of swap space, and a 32-bit processor (and 3/1 memory split in the kernel). In this setup the application only has 3 gigs worth of accessible address space, and if it uses it all, the system still has 3 gigs of virtual memory available for other use.

      Of course the darn thing could be forking child processes...

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    28. Re:If you have enough, none by hackstraw · · Score: 1

      exactly... and some OSs (read: OSX) caches less-frequently used data (cached window contents, and other images, etc) to the drive to free up real RAM; it doesn't matter how much RAM is installed on the machine, it'll still use the swap. Even my machine at work with 8GB of RAM frequently uses the swap even before 1/4 of the RAM has been touched

      exactly back at you :)

      Its also good for an OS to page out "dead code". Things like initialization code or stale data or whatever so that real RAM can be used for disk cacheing and allowing new apps to do their thing.

      It frustrates me when a user runs something that takes all of the memory on a box, but it happens. Hell, I've even done it compiling some code where the preprocessor ran my box out of memory. Some seriously nasty C macros. Gotta love those new CS guys :)

    29. Re:If you have enough, none by v1z · · Score: 1

      I actually experimented with this on my new Laptop (an asus v3j, 1GB ram, ati x1600 gpu). Running most windows-apps w/o swap was no problem -- but when windows suddenly closed down Oblivion after a few hours of play, it was time to enable swap again...

      Ofcourse, mobile gpus put an extra strain on the main memory, and it's not really a surprise that I ran out -- but it goes to show that it can be harder to define enough, than one might think (yeah, I hear you scream 2GB -- but laptop ram isn't exactly what I'd call cheap).

      As I see it, running without swap has extra potential benefits on a laptop -- allowing the hd to spin down. On the other hand, it might be that if you have a lot of long-running,large binaries, with large portions that are unused -- swap might actually allow the hd to spin down sooner.

  5. Enough... by talkingpaperclip · · Score: 3, Funny

    640k should be enough for anybody.

    1. Re:Enough... by mgblst · · Score: 1

      Funnily enough, 640,000 is the number of times this joke has been used on Slashdot. It never gets old, though!

  6. Equal to. by digitalsushi · · Score: 1

    I just make mine equal to my ram these days.

    --
    slashdot: where everyone yells sarcastic metaphors to themselves to understand the issue
  7. I use this by Anonymous Coward · · Score: 5, Insightful

    2X physical memory for under 2G RAM
    2G swap for up to 8G RAM
    +1G swap for every 4G RAM beyond that

    1. Re:I use this by Asm-Coder · · Score: 1

      You can load more than 4gig on a computer. I know Windows combined limit used to be 4gig ram + virtual, but I didn't ever encounter a limit on any other OS. But I've never seen a motherboard capable of handling more than 4 gig of ram.

    2. Re:I use this by afidel · · Score: 1

      Windows 2003 Standard x86 is limited to 4GB of virtual address space. 2003 Enterprise x86 is limited to 64GB. Full details available here. Personally I work with server with more than 4GB daily, though so far none of ours have more than 4GB per processor board =)

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    3. Re:I use this by Malc · · Score: 1

      1x-2x for 2GB

      I use a range so that I get a warning from Windows when it is increasing the swap space. I really don't want to be using the maximum value because everything is slow and the hard drive is being thrashed. With more memory, I don't need so much virtual memory - it's just there as an emergency buffer if I have a run-away process or run a new app that I'm not used to.

      Every watched SQL Server? It does not swap. Instead it reduces its memory demands when the system needs more RAM. Interesting solution. Makes sense too... all it's data is already on disk. Sorry, tangential...

    4. Re:I use this by Malc · · Score: 1

      Ooops: should have proof read. I would have spotted /. treating my text as HTML...

      This is what I tried to say:
      1x-2x for <= 1GB
      0.5x-1.5x for <= 2GB
      512MB-1024MB > 2GB

    5. Re:I use this by kdekorte · · Score: 1

      This is pretty much what I use as well... I find it works well for most "desktop" applications.

    6. Re:I use this by Felius · · Score: 1

      That's a pretty reasonable rule of thumb, though on the newest system I'm looking after it'd result in a 96GB swap file. ;)

      --
      ..and I'll form the head!!
    7. Re:I use this by Anonymous Coward · · Score: 0

      Big unix servers often have a lot more than 4G :)

    8. Re:I use this by TheNetAvenger · · Score: 1

      but I didn't ever encounter a limit on any other OS.

      Ok, not sure about what 'limit' you are talking about, but virtual and even Page File Sizes (depending on OS) are based on the OS and CPU architecture.

      A 32bit OS is going to be limited to 4GB of RAM unless they use the (IA32) extensions, it doesn't matter if it is Windows, BSD, Linux or DonkeyOS.

      The way this RAM is broken up can be different and that is where there are some gives and takes in each OS. Windows for example natively will only allow an application to have 2GB of RAM, leaving the additional RAM for the kernel/processes. There is an override for this that allows Windows to allocate 4GB processes as well, and with a give and take in the Kernel allocation.

      So for a 32bit System, Windows normall allows for 4GB to 64GB of Physical RAM depending on the version of Windows and whether IA32 is used or not.

      On a 32bit Windows OS, the PAGEFILE, is in theory limited to 16 terabytes. (Considerbly more than Physical RAM)

      On Windows 64bit, in theory the physical RAM limit is 16 terabytes, with a 512 terabyte limit on the pagefile, but again, since most of the 64bit architectures like AMD64 don't give a full 64bit memory address space, this is not able to be fully used.

      So again, not sure what limits you are talking about and why you think Windows or any other OS would have inherent benefits when they are hardware limited based on the CPU/Architecture.

    9. Re:I use this by Asm-Coder · · Score: 1

      Thank you, that clears up a lot. Wish I had some mod points.

  8. 1GB ram using XP by Karloskar · · Score: 3, Informative

    I disable virtual memory on computers with more than 1GB of ram unless the user is going to be manipulating large images. Never had a problem yet.

    1. Re:1GB ram using XP by goarilla · · Score: 1

      You don't always know if your process is gonna handle large images
      A short example click on this link http://conceptart.org/forums/showthread.php?t=7241 9
      My brother posted this link to me once because
      When i clicked the link and watched all of the pictures ... my ram was gone and i only had 80 mb swap left :S
      I couldn't even admire the next round without killing firefox first

    2. Re:1GB ram using XP by fitten · · Score: 1

      You disable virtual memory? That can't be good. I'm assuming you mean the swap file, which is not the same thing as virtual memory. In any case, conventional/modern recommendations is to leave it alone and leave it set at letting Windows manage the size. There are oodles of postings as to why (search for posts by DriverGuru, particularly on ArsTechnica) you should do this. It's a question that comes up frequently.

    3. Re:1GB ram using XP by izomiac · · Score: 1

      Hmm... I was using 150 MB of memory before loading that page and went up to 350 MB. This is on an XP system, 1 GB of RAM, no swap file, large system cache, and IE (between reformats so I got lazy). I'm at just over 1/3 usage, so I don't see the problem. I regularly view huge images and this hasn't been an issue for me except with older versions of Firefox (caused unstability in Windows and images just stopped loading in BeOS, but I only had 512 MB at that time). By "huge images" I mean about 20 tabs with about 15 x 1 MB images. I suppose my setup is worse for memory leaks, but I figure that if my RAM fills up then my pagefile wouldn't be far behind. But, everyone's needs are different, so if you need 20 apps in the tray and play some RAM-hungry games then 1 GB probably wouldn't cut it.

    4. Re:1GB ram using XP by deviceb · · Score: 1

      -at least somebody mentioned this. i Ctrl+X/C & Crtl+V all the time with images or data blocks over a gig. So i stick to the 1.5 ratio from back in the win98 days..

      Swap space is not always used by simple processes..

      --
      Kill your TV
    5. Re:1GB ram using XP by bhadreshl · · Score: 1

      You think you disabled virtual memory, but little do you know it comes creeping back.
      Try going into system properties > advanced > settings > set no paging file. Than restart your computer, look on the C drive for c:\pagefile.sys. It will reappear and you wont be able to delete it because windows is using it

    6. Re:1GB ram using XP by goarilla · · Score: 1

      i've got 256 mb ram and use slackware-current :S

  9. Depends... by PianoComp81 · · Score: 1, Informative

    It depends on what you want to use. If you don't care about Hibernate mode, then you probably wouldn't need any swap (or much). However, if you want to use that mode, you need to have at least the same amount of swap space as memory. I've tried it with less, and it wouldn't even attempt to go to sleep (for obvious reasons - swap is used to store what's currently in RAM when going into hibernate mode).

    1. Re:Depends... by Anonymous Coward · · Score: 0

      No it's not.
      There's a seperate hibernation file for this purpose, hiberfil.sys in c:\ (or whatever disk you have windows on)

    2. Re:Depends... by aminorex · · Score: 1

      So what happens to the data that is already in swap, if your swap is all required in order to hibernate? It's an endless recursion, unless you have a swap partition that you are not currently swapping on, to which your system is yet clever enough to hibernate.

      --
      -I like my women like I like my tea: green-
    3. Re:Depends... by Limecron · · Score: 4, Informative

      This is completely wrong.

      In Windows, your RAM is saved to a file called "hiberfil.sys" which is the exact size of your physical RAM. Your swap file stays exactly the way it is, otherwise you'd lose the data that was swapped to it.

      In Linux, it depends on what program you are using to suspend, but typically, it's a file in /tmp.

    4. Re:Depends... by cnettel · · Score: 2, Informative

      A note regarding Windows, though: from XP and on, it's very rary that the complete hiberfil.sys is used. Pages are swapped out aggressively to general swap or whatever binary file that's backing read-only pages. The remaining pages are compressed. However, when all these decisions are made, it would be impossible/inconvenient to realize that the file was really too small, so a worst-case allocation is made.

    5. Re:Depends... by gyrojoe · · Score: 2, Informative

      swsusp stores the data in the swap partition.
      Suspend2 can write it to a file instead.
      See http://www.suspend2.net/features

    6. Re:Depends... by Malc · · Score: 1

      They're talking about Windows and how it handles hibernate and swap. So why are you talking about Linux?

    7. Re:Depends... by PianoComp81 · · Score: 1

      Because *I* was talking about Linux (there is no swap partition with Windows). I must have used swsusp last time I set up my system, as without enought swap (actually 1.5G swap for 768M of RAM), I couldn't suspend to disk. Hibernate is just another word for it (been using it at work, unfortunately and got stuck in my head).

    8. Re:Depends... by Griffyn · · Score: 2, Informative
      for obvious reasons - swap is used to store what's currently in RAM when going into hibernate mode

      Nope. There is a separate file called hibernate.fil (I think) that's stored in the root folder of the same drive containing your Windows folder.

    9. Re:Depends... by snotty · · Score: 1

      This is blatently wrong - hiberfil.sys is your hibernate file... When Windows hibernates, it writes the contents of your RAM to disk, and that is why hiberfil.sys is the same size as your RAM. This should not be set as "5" for informative and needs to be set to "1"...

    10. Re:Depends... by exit3219 · · Score: 1

      Yeah, but that doesn't mean you need a swap partition as big as your RAM. Swsusp2 uses LZF compression, which usually compresses the 768MB of RAM on my machine down to a mere 300MB or less (that depends on the situation, though). If you never use all of your physical RAM, or if most of it is used as cache, you can rely on swsusp2 even with a swap partition smaller than how much RAM you have.
      (For the record, I have a 1G swap partition, because I sometimes open a large .psd in the Gimp or play Half Life in WinXP ;)

      --
      http://ascending.wordpress.com/
    11. Re:Depends... by exit3219 · · Score: 1

      That's hiberfil.sys Windows has a tendency to use .sys everywhere so that it scares courious people away. It also marks it as a 'protected operating system file', so that it's hidden by default.

      --
      http://ascending.wordpress.com/
    12. Re:Depends... by Anonymous Coward · · Score: 0

      This is wrong - hiberfil.sys is used for hibernation.

    13. Re:Depends... by Malc · · Score: 1

      Hmmmmm. Linux is absolute shit when it comes to hibernate/suspend-to-disk. It's so many years behind Windows, it's unbelievable. It's a feature that I've found indispensible since I discovered it in Windows 2000, especially when having to multi-boot between OSes - Linux's deficiencies become glaringly obvious when one has to restore state (wait for it to boot, restart apps, re-open docs, etc) several times per day. Thankfully I have very little need for Linux on my desktop/laptop these days, just my headless Debian P75 server chugging away at home.

    14. Re:Depends... by 42forty-two42 · · Score: 1

      Actually, Linux does use swap to suspend. It simply swaps everything to disk, syncs, discards the cache, then writes out whatever kernel memory is left. When it resumes, it just reads back in the kernel memory, and lets the programs swap back in.

  10. LVM by XanC · · Score: 2, Informative

    If you use LVM (which you should, it's great!), you can expand and contract your swap partition as needed.

  11. Well, there's what I do and then there's reality by TLouden · · Score: 3, Informative

    If you really want to know, I use 1-2 GB swap with 1GB ram and the same for 512MB ram.

    However, you might just do what I do and try out different values to figure out what works. If you're talking about a linux system a real-time memory/swap usage graph can be added to most window managers so that you can see what's happening. You could also try to estimate usages based on what the machine is expected to do.

    --
    -Tim Louden
  12. Think for the future by solafide · · Score: 1
    I have 10GB swap on my desktop with 2.5GB RAM, because I have 700GB of hd space, and I don't have to be conservative with it. 10GB is enough for any application that I'm liable to install to need for the next, eh, 4 years, and in 10GB swap you can have some incredibly huge python range() arrays.

    On the other hand, on my laptop with 256MB, I have (iirc) 1GB swap, and on my laptop with but 96MB ram, I have (again, iirc) 25% of my disk in swap. (But then, the disk is only 2GB anyway...)

    So do as much as you can spare. Sure, you may never use it, but hd space is cheap these days.

    1. Re:Think for the future by Millenniumman · · Score: 1

      Hard drive space is cheap and plentiful for desktops, but it is scarce, no matter how much you are willing to spend, for laptops. The biggest for a SATA drive is 120GB, and the biggest laptop drive is 160GB. And with a laptop, an external drive is not a convenient option.

      --
      Stupidity is like nuclear power, it can be used for good or evil. And you don't want to get any on you.
    2. Re:Think for the future by Barny · · Score: 1

      Yeah, the OP asked the wrong question, should be "what % of your very cheap hdd storage do you use for swap?".

      Personally i use 5G of mine, thats enough should anything start gobbleing it up (have seen one buggy game use over 6G once, 1.8 in real mem rest was swapped).

      But then, i beta a lot of games that have memory handleing like the titanic had water pumps ;)

      --
      ...
      /me sighs
    3. Re:Think for the future by ShecoDu · · Score: 1

      You should start using xrange() if you're going to be doing long iterations.

      Not only because of the memory needed, but because with range() you need to allocate everything first, and then read everything, but with xrange() you only allocate the item you'll be reading.

  13. Excuse me while I reminisce... by ian_mackereth · · Score: 1
    The first time I used a friend's 128k RAM Macintosh, I noticed how busy the HD seemed to be.
    After some poking around in the system, we found that we were in the topsy-turvy situation of having the OS running in RAM and all the applications running in the swap file on the HD!

    As soon as he got rid of the silly voices and other frippery (cool, though!), it went back to behaving in a more sensible manner.

    I think RAM prices have fallen faster than HD speeds have risen, so it has more impact than it used to to have applications requiring swap file space.

    1. Re:Excuse me while I reminisce... by Anonymous Coward · · Score: 2, Informative

      You're full of it.

      1. The 128 KB Mac did not have a HD (though there were some companies that made disks that plugged into the floppy port).

      But more importantly:

      2. There was no "swap" (Virtual Memory) for the Mac OS until System 7, which wouldn't run anything less than a Mac Plus.

    2. Re:Excuse me while I reminisce... by lubricated · · Score: 1

      yeah, I looked at that funny too. It makes sense though if he meant 128MB.

      --
      It has been statistically shown that helmets increase the risk of head injury.
    3. Re:Excuse me while I reminisce... by Anonymous Coward · · Score: 0

      The 128k Macs did not have a HD (or a SCSI port to hang 'em outside). The SE was the first to be blessed with a HD.

  14. More is better! by Millenniumman · · Score: 5, Funny

    I use 4x750 GB hard drives (RAID), purely for virtual memory. It increases the speed on the RAM preprocessing directive, but demodulates the core processing utility monitor. I find it to be a good setup, especially for running Naibed Linux.

    --
    Stupidity is like nuclear power, it can be used for good or evil. And you don't want to get any on you.
    1. Re:More is better! by SilentUrbanFox · · Score: 1

      You forgot to mention the deflector dish.

    2. Re:More is better! by Minwee · · Score: 1

      That's Naibed Linux/UNG to you.

    3. Re:More is better! by Alaria+Phrozen · · Score: 1

      I'm seeing two schools of thought, and the parent sums up the "silly one" nicely.

      I am Joe User - I play on a Windows XP SP2 machine with 2 gigs physical ram. I will play World of Warcraft, EVE Online, I run Firefox with 30+ tabs, iTunes, Outlook Express.. sometimes all at the same time. I have _0_ swap file.

      In fact, a year ago when WoW was new-er I was having a LOT of lag. Epic lag. Ironforge lag in particular. I ran a task manager and a few Adminitrative Tools to see what was actually causing the bottleneck. ALL OF IT WAS HARD DRIVE ACCESS! Boosting my memory from a "pathetic" 512 MB ram (in WoW's terms, it is) to 2gigs eliminated the problem.

      All you people that are claiming "but if you ever accidently run Half Life 2 ontop of all that, you'll run out of real memory and your system will crash!" Well guess what? If the majority of your allocated memory for Half Life 2 is swap file you will wish it crashed. I bet your quad SLI dual-core rig will run really nice swapping away on good ol' HL2. I'm not sure on the exact numbers, but the transfer speed of memory vs harddrive swap file is on the order of several magnitudes greater.

      Rules of thumb are dumb! The poster is a genius, mod him up! Now if you're a 3D-StudioMax9 artist that likes to run Maya and some ridiculously awesome video editing software all at once, get yourself some swapfile.

    4. Re:More is better! by jumbledInTheHead · · Score: 1

      How did this get modded insightful?

  15. Set it and forget it by StikyPad · · Score: 4, Insightful

    According to MS, it's 1.5 times the total RAM. I assume you're asking because you're trying to avoid a fragmented page file. While the benefits of an unfragmented page file are dubious at best (since it will be randomly accessing different parts of the page file), it's better to err on the side of caution: If you have 2GB of memory, you likely have an equally compensating-for-something hard drive, so you probably won't miss 3GB of space, or even 4. It's better to waste a little space than have Windows run out of Virtual Memory. Otherwise, just let it do its dynamic page file adjustment thing.

    If you're asking about creating a swap partition for Linux then 1.5X is also recommended. Just be generous, unless -- for some reason -- you've got 2GB of RAM and a 50 meg hard drive. Too much is always better than not enough.

    1. Re:Set it and forget it by Anonymous Coward · · Score: 0
      While the benefits of an unfragmented page file are dubious at best (since it will be randomly accessing different parts of the page file)
      The benefit of an unfragmented page file is not for the page file itself, it's for the rest of the file system. Fewer fragments on the page file means larger continuous blocks for the rest of the disk...
    2. Re:Set it and forget it by Doctor+Memory · · Score: 1

      This seems like a reasonable limit to me. The last time I installed Solaris it wanted to give me ~800M (on a machine with 1G of memory), I overrode it to take a gig. Of course, under Solaris /tmp is mapped to swap space, so it's usually a good idea to give yourself a little more room anyway. OTOH, even debugging stuff in NetBeans while running Sun's app server, I've never eaten more than half a meg of swap, so it looks like Solaris at least has a pretty good swapper. I do recall the only time I ever had NetBSD crash on me, I was rebuilding the kernal and passed "-j" as an argument to make(1) (which tells it to create as many subprocesses as it wants to process things in parallel). Ran out of swap and everything went dark....

      --
      Just junk food for thought...
    3. Re:Set it and forget it by Dare+nMc · · Score: 1

      I found it funny MS recommends putting swap on it's own partition, then simply says it's due to fragmentation if it expands, on the shared partition.

      Was this advice written by partition magic? you can't resize partitions with microsoft utilities, so if you happen to need more swap later, your screwed with the separate partition, if not need then they state no other advantage.

      "When you put a paging file on its own partition, the paging file does not become fragmented, and this counts as another definite advantage. If a paging file resides on a partition that contains other data, it may experience fragmentation as it expands"

    4. Re:Set it and forget it by east+coast · · Score: 1

      I assume you're asking because you're trying to avoid a fragmented page file. While the benefits of an unfragmented page file are dubious at best...

      Would the system suffer if the page file was put in it's own partition? If so, why? I think that would be the best way to avoid fragmentation of a page file.

      I actually have two systems set up this way and have never noticed any performance problems but I don't know if there is something more to this that I simply don't understand. Any insight into this would be helpful.

      --
      Dedicated Cthulhu Cultist since 4523 BC.
    5. Re:Set it and forget it by FishWithAHammer · · Score: 1

      You can set the Windows page file with minimum/maximum sizes, i.e. 256MB at low state, and adding up to 512MB if you need more. That's what that means.

      Don't be a jackass.

      --
      "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
    6. Re:Set it and forget it by Politas · · Score: 1

      2GB of memory and limited HD space is quite common on a laptop. I've got 2GB RAM on my laptop and a 60GB HD, which is split between Windows and Linux.

      --

      Politas

    7. Re:Set it and forget it by Anonymous Coward · · Score: 0

      I'm using Windows 2000 on my desktop. I have 1GB of RAM and my pagefile is set to 512MB min, 1.5GB max. pagefile.sys is currently 768MB and was last modified on 8-14 (Today is 8-30)

    8. Re:Set it and forget it by Tim+C · · Score: 1

      If you have 2GB of memory, you likely have an equally compensating-for-something hard drive

      I have 2gig of RAM, and do indeed have a compensating-for-something hard drive - it's compensating for the fact that in my previous machine I was forever running out of space. As it is, I have 500GB worth of disk space, of which a little over half is used. If I maintain usage at this rate, it'll be full by about Feb next year...

  16. Don't forget disk cache by uler · · Score: 5, Insightful

    One of the real advantages of using swap isn't to avoid memory exhaustion at all; by moving infrequently accessed pages from memory you make more room for the disk cache, thereby possibly improving overall system performance by reducing hard drive reads.

    1. Re:Don't forget disk cache by pe1chl · · Score: 3, Interesting

      Unfortunately the Linux system has a hard time determining what are "infrequently accessed pages" and what are useful pages to keep in the disk cache.

      This is most obvious when you are copying large amounts of data, e.g. during a backup.
      Say you have a 250GB disk and you copy it to another one. The system will continously try to keep the files you have read in disk cache (because you may read them again) and try to keep room for many dirty pages that still have to be written to the destination disk (because you may change them again before final writing).
      All of this "(because)" is never going to happen as everything is read once and written once and then no longer needed.
      But still, it will swap out running processes to make room for the above.

      The net effect you see is that the source and swap disks are very busy, the destination disks sits idle long times until the kernel feels like flushing out some dirty buffers, and the other programs slow down to a crawl fighting for the swapspace.

      It can be tuned with the "swappiness" variable but it remains a tough thing to control. It looks like Windows does a better job in this (not so hypothetical) case.

      There should be some "file copy mode" (used during backups and other large tree copies) where it:
      - discards all disk USERDATA caches immediately after use (directory and other filesystem allocation data may be kept)
      - immediately writes out any written USERDATA to the destination disk, not having it populate the dirty pages until bdflush comes around to write them
      - keeps re-using the same small set of buffers to pump the data from source to destination, without stealing memory from others

      Issue is of course: how could this mode be enabled. It could be a special systemcall, but who would call it and where?
      Personally, I would already be happy with a program like "nice" or "ionice" that would run a commandline in a special mode (e.g. with a very small buffer quota) to force such behaviour. But the world at large would of course be better serviced if this would happen automatically when lots of data are copied sequentially.

    2. Re:Don't forget disk cache by 0123456 · · Score: 2, Funny

      "It looks like Windows does a better job in this (not so hypothetical) case."

      LOL. Windows will swap out my web browser when I'm copying a 2GB file from one drive to another.

      The whole idea of kicking out real applications to increase disk cache size is absolutely retarded. Unless the cache is below some absolute minimum size, it should never, ever swap out an application just to try to cache data that I'm probably never going to use again. The operating system has no damn clue about how important a file may be so it should never be trying to make these kind of decisions for me.

      Similarly, last night I left my PC running, and Microsoft Antispyware did a disk scan, which meant that Windows swapped out all the applications in order to increase the disk cache size to cache files that the Antispyware program was going to read once. It literally took five minutes of thrashing to get back to a usable system, while providing absolutely no damn benefit whatsoever.

    3. Re:Don't forget disk cache by poot_rootbeer · · Score: 1


      So when the CPU expects to get data from the hard disk, we sometimes get it from memory instead, and when it expects to get data from memory, we sometimes get it from the hard disk instead.

      This does not seem optimal to me.

    4. Re:Don't forget disk cache by pe1chl · · Score: 1

      Well, my Linux workstation behaves exactly like that (e.g. when I switch on the display at work after the system has been on during the night, making a backup etc, I have to sweep the mouse across all windows to force the apps to page-in all their lost memory).
      However, I do not see this as much in Windows. Maybe it depends on the version, we use Windows 2000 SP4. I think older versions did not even have this "the entire memory can be used as a disk cache" feature, so it wasn't there to bite you.

    5. Re:Don't forget disk cache by Anonymous Coward · · Score: 0

      It does to me.

      "Program Memory" is far less smaller than "Data".

      If your computer had to swap program memory out because you needed more disk cache, the program should swap back in relatively quickly when used again. Lets take for example, Mozilla. It uses 41 MB of program memory. If it was swapped out entirely, the swap back in should only take at the most 2 seconds. That is probably slightly faster than starting it up the first time, and you have the added benefit of getting back to where you left off. Also, if you frequently open and close an app like mozilla, then the program's raw code is likely in the disk cache, and will start pretty much instantaneously (as fast as your cpu really).

      It seems like the average desktop today is now going to have 1 GB of ram. Average desktop apps ram use will probably weigh in around 200 MB in the worse case scenarios (of course I'm looking at linux). Games use more but considering those are pretty much one time sole use things this sort of interactivity is not required. So it's not unfathomable that you'll infrequently need any swapping. However, basing on what I've seen, when working on large files of data, the more ram available, the faster it will go. Swapping out an additional 100 MB or so wouldn't hurt and you'll gain speed and go much faster. Swapping in 100 MB of programs back in won't cost much more than a few seconds.

      However, if swapping makes your computer slow for you, you probably should add more ram because it's for data afterall, and not make it more difficult to swap by adjusting swappiness.

  17. Still 2-3x physical RAM by georgewilliamherbert · · Score: 1

    I still use a small multiplier, typically 2-3x physical RAM, for swap partition sizes on Solaris, Linux, xBSD, etc.

    Systems typically are paging less now that we have multiple gigs of RAM per server, but if something goes wrong, the disk is so cheap that having the overhead installed and ready to use is fine. Having a live, active safety margin is just good sytem planner sense.

    If you skimp on OS hard disks so much that 2-3x physical RAM is an excessive chunk out of the hard disks, then you're doing something wrong.

    1. Re:Still 2-3x physical RAM by gfxguy · · Score: 1

      It's not trying to scrimp on disk space, it's trying to improve performance. The theory is that if swapping slows down the system, then why bother when you have enough memory?

      The counterargument is that swap never hurts, so why not give up a couple GB. Given X amount of RAM versus X amount of RAM plus Y swap will never perform worse and may perform better.

      --
      Stupid sexy Flanders.
  18. Remember though... by spysmily1 · · Score: 1

    I'm not sure about any nongaming applications, but some games require that you have a swap file regardless if you need it or not. This will usually be indicated by an error message stating this fact or some other oddball message. Of course this is an easy fix, just start using a swap file again

    --
    Videogames made me kill people...I also eat mushrooms to grow bigger.
  19. auto by Joe+The+Dragon · · Score: 3, Insightful

    just let windows set it for you.

    1. Re:auto by Mordaximus · · Score: 1

      Yes. Because fragmented paging files work best.

  20. How Much Virtual Memory is Enough? by fishtop · · Score: 1

    The conventional wisdom was (1) for Windows and (2) when memory was a lot more expensive. In general, you never want to use virtual memory. You absolutely never want to need it. This has been true since the days that swapping was done to fixed head drums. You do not want to rely upon it while you are doing anything important. Get enough real memory, and set the virtual memory to whatever makes sense for your usage pattern.

  21. My rule by Nezer · · Score: 1

    Here is my rule and is founded on years of managing Unix/Linux systems professionally.

    Never, ever use less than 1x physical RAM. Some operating systems use swap space on disk to through core dumps on a crash (Digital Unix... err Tru64 is one). Without a single swap space big enough to hold a physical RAM dump you might be SOL when it comes time for the vendor to diagnose. (In the case of Tru64 you're already SOL because they can't diagnose anything.)

    2x physical, which is what I was always told as the recommended amount, is just ludicrous. It was then and it is even more so now.

    So my rule is, first, know how much memory your machine uses under heavy load but not when the system is ailing because of an app leaking memory or some other out-of-the-norm issue. Now add that, plus a reasonable margin of error (I like 50%), to your physical and you have a good number. Remember what I said above about always having at least physical? It's very likely (though I've never run into this issue) that a system that wants to dump core to swap space may very well want to dump what's in active swap along with it. As far as the OS is concerned this memory space can be important (though, in the case of a system panic it seems impossible that the offending code would be sitting in swap space).

    It should go without saying but the amount of paging space actually used should always be kept to a negligant amount. If this gets out-of-hand you need to add more RAM.

    Finally, it's better to err on the side of too much than too little.

    1. Re:My rule by Anonymous Coward · · Score: 0

      As memory serves (haha!), under certain Unices popular at the time Linux first started attracting attention, the 2x rule was a necessity. The reason was: memory writes went to both physical ram and the swap space. It sped up swapping out (you could just throw away the physical pages, since they were mirrored in swap), and if you had less than 1x physical you weren't getting any benefit at all. (And although it may have seemed ludicrous if your OS of choice didn't do this, it wasn't ludicrous if you had to take away your physical memory's size...)

      Obviously, neither scenario is the case any longer, so pretty much it's useful as a buffer to hold little-used memory (for instance, initialization code on applications you start and leave running for a long time), or as an emergency buffer when memory usage spikes.

  22. Chicken Cross Road by Anonymous Coward · · Score: 0
    To get to the other side!

    Mod me up, Baby! You know that's at least as funny as the parent post!!

  23. You've got virtual memory?!? by EmperorPenguin · · Score: 1

    Let's create a ramdisk!

    1. Re:You've got virtual memory?!? by ichigo+2.0 · · Score: 1

      I got an even better idea!! Let's use the ramdisk for swap!!11

  24. Still using the convention... to a point by cyanics · · Score: 1

    I typically will use no less that 2g for swaps, however, as the more memory is added to the system, the less swap I use.

    It is never less than 1 - 1.5x the ram size. You NEED to have enough space to dump the entire contents of memory out in the event of a panic (for tracing) and then anything else that is still resident in swap at the time. Start with 2GB and add 1GB per 512MB of memory. You should be sitting safe in most situations.

  25. Let the OS decide by hackwrench · · Score: 1

    I let the operating system increase and decrease as it sees fit. It has a better picture of the situation than I do. I use Windows XP, though. Is this possible in Linux? I find it strange that someone hasn't mentioned this already. Usually the latest beta of Firefox, Minefield, triggers the OS to grab more.

    1. Re:Let the OS decide by KillerBob · · Score: 1

      Linux doesn't work that way. Of course, Linux also has a significantly lower memory overhead, usually, and is also a lot more conservative about how it allocates memory. Usually, a system won't actually start swapping unless you have a huge number of programs open, or you have very little physical memory.

      Case in point... my laptop has 1GB of RAM. Not really that much by modern standards, if you ask me, but not really important, either. On the laptop, I have had, at the same time, GAIM, gxine (listening to streaming audio from Club977), GIMP (like Photoshop), and running through Cedega, Guild Wars. On a system with an Athlon64 3500+ and 1GB of RAM, there was absolutely no swapping happening at all. Now, I've got 2GB of SWAP set up on that laptop, but with that much stuff open at the same time, it says something that there's no swapping happening.

      By comparison, my desktop machine runs Windows XP Professional (yes, it's legal). Said machine has an Athlon64 3000+, so it's pretty much comparable to the laptop at that end. It also has 2GB of physical RAM. Also, where the laptop has a Radeon XPress 200M 128MB, the desktop has a Radeon X1300 256MB. Strangely, under XP Pro, I have had my system slow down to an absolute crawl while playing a single instance of Guild Wars (and having nothing else running), because I had set the swap to start at 32MB and grow to up to 1024MB. Why? Because even though Windows had twice the physical RAM of my laptop, and even though Windows didn't have nearly as many programs open, Windows still felt the need to increase the size of my swap file because it was doing swapping. Ultimately, I set the swap on that machine to be permanently 1024MB.

      The Winbox has a *lot* more overhead, and the Windows OS is significantly more liberal in its memory use and memory distribution. It's not as good at garbage collection. And before somebody points it out... the lappy is running Linux 2.6.17.8, with X.Org 6.9 and XFCE 4.3.90 with compositing enabled (and full transparency effects), and ClamAV 0.88.2, on top of SSH server, cpu frequency scaling (the Conservative governor, usually underclocking to 1GHz from 2.2GHz peak). The Windows machine, at startup, is running AVG Antivirus, RKLauncher, Window Shade 1.2, and... Windows.

      As to the actual question posed... it's been answered dozens of times, but I may as well chime in with my $0.02. As you can probably guess, how much virtual memory you need depends on what you're doing, and what OS you're using. Under Linux, with a respectable amount of memory and reasonable use, I would say you don't need virtual memory at all. By Respectable, I'd say 1GB+. If you're running less than 1GB of RAM, or if you're going to do some heavy use, I'd say 1:1 Physical:Virtual, with a caveat: Physical + Virtual should probably be at least 1GB. Under Windows? Let the system manage it, most of the time. Just make sure that you don't let the system give you so much virtual memory that Physical + Virtual > 4GB... All versions of Windows that are currently available only create memory addressing space for 4GB, and any more than that simply won't be used. Vista changes how memory is addressed, but it's not on the market yet. :)

      --
      If you believe everything you read, you'd better not read. - Japanese proverb
  26. Pre-emptive swapping... by Junta · · Score: 5, Informative

    Linux has futzed with this a lot (and lets the user tweak VM behavior a lot, but /proc/sys/vm/swappiness goes a long way...), both linux and Windows will swap well ahead of not having free memory (for good reason). Just wanted to go into detail because I keep seeing people complain that they see swap used in linux or windows when they still have free memory, not realizing this isn't a bad thing generally.

    There are generally two strategies:
    -The common-sense one where you swap when you run out of memory. This makes a lot of practical sense on systems with limited write cycles (flash based swap, though you really never ever should do that anyway), and systems that want to spin down drives to conserve power for battery conservation. Performance wise (this may surprise people who haven't spent time thinking about it), this can often be bad. Avoiding swapping is generally only good on systems where resource utilization is carefully managed and you know it won't swap ever (the IO operations of unneeded can interfere with the productive activity of a constantly busy system). This is actually a vast minority of systems in the world (no matter how l33t one may think themselves, they most certainly don't have a usage pattern that would be impacted by the extraneous IO operations of occasional write to swap.

    -Pre-emptive swapping. When the IO subsystem is idle and the system can afford to copy memory to swap area, it does so (depending on criteria). Generally speaking it will select memory not accessed much and write it to disk, but leave the memory copy in place if the physical memory is not immediately needed. A fair amount of swap used in an apparently underutilized system is duplicated in physical memory and swap space. The benefit here is that if the process reads back that memory, it doesn't incur any penalty in reading it back despite it being also in swap (the system may make certain decisions on what is the best swap candidate and write to disk different data). The benefit of writing this stuff to swap even when not needed is clear when an application comes along that allocs more memory than the system has free in physical space. In the first strategy, this means the malloc blocks while data is written to disk, and the new application starting or needing a lot of data is severely impacted. In the pre-emptive swap case, system notices the condition, knows what memory it has a backup in swap of that hasn't been used lately, and can free that memory and satisfy the malloc pretty much instantly.

    To those who have 1GB of RAM or so it becomes less likely that the system will have to flush memory from physical RAM, but there is a balance to be struck between memory used directly invoked by applications, what the application memory access pattern is, and what ram you can use to buffer filesystem access. If your total application memory allocation is 75%, it still may make sense performance wise to only keep 50% of your physical memory dedicated to the applications, (the other bit relegated to swap), and 50% of the memory to buffer disk I/O.

    --
    XML is like violence. If it doesn't solve the problem, use more.
    1. Re:Pre-emptive swapping... by afidel · · Score: 1

      My response is that preemptive swapping on Windows can often be too agressive. If I launch a game like WoW then all of my other processes get swapped out, even though I have 1.5GB of ram and the WoW process only takes ~500MB max. This means that while I have ~700MB of free ram whenever I alt-tab my browser and other programs have to get swapped back in from disk, a slow and annoying process. Is it good to user some ram as a disk cache, yes, but at what point does it become counterproductive? Personally I wish there was some way to tune this.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    2. Re:Pre-emptive swapping... by L0stm4n · · Score: 1

      Where are my mod points when I need them?

      Get this guy ro +5

      --
      superman runs linux
    3. Re:Pre-emptive swapping... by cookd · · Score: 2, Informative

      That's not due to pre-emptive swapping. Pre-emptive swapping makes your hard disk work more when the system is idle, but it doesn't force anything out of memory.

      Your issue is due to an incorrect decision somewhere (not sure where) about how much memory to make available to WoW's direct (memory allocation) and indirect (disk cache) needs. WoW IS taking advantage (directly or indirectly) of that extra memory, but it probably only makes a 0.1% performance difference and you would rather it left your other programs in RAM. That is a hard situation to tune for.

      Note that there are (at least) two different ways for memory to be used even when it shows up as "free". One is via disk cache. The other is via large temporary allocations that are made, used, and then freed before they really register on the performance monitor.

      --
      Time flies like an arrow. Fruit flies like a banana.
    4. Re:Pre-emptive swapping... by m0rph3us0 · · Score: 4, Informative

      It's a problem called free-list errosion. Windows will swap out apps to make room for buffer cache. So when WoW reads a 2GB file, all your programs end up swapped out to disk.

    5. Re:Pre-emptive swapping... by Anonymous Coward · · Score: 0

      Mod this ^ asshole down... ;-) Where are MY mod points when I need them?

    6. Re:Pre-emptive swapping... by Anonymous Coward · · Score: 0

      this is weird.
      I play WoW on linux via cedega and i also have 1.5GB of ram and if i start WoW the first thing it does is fill up ATLEAST 700MB of that.
      over the course of playing it will slowly nible away 1GB of ram.

      But it certainly does not start throwing other processes to swap. I can alt tab all day long while in wow or switch to other workspaces, but all programs still respond snappy, like they would if i wasn't playing WoW.

    7. Re:Pre-emptive swapping... by Kjella · · Score: 1

      It's a problem called free-list errosion. Windows will swap out apps to make room for buffer cache. So when WoW reads a 2GB file, all your programs end up swapped out to disk.

      Amen to that. I really wish there was a way to limit the amount Windows would use for system cache. Anyone know of any magic registry keys that'll do this? Because my box isn't swapping alot, but when it does it's unnecessary and because of exactly this.

      --
      Live today, because you never know what tomorrow brings
    8. Re:Pre-emptive swapping... by dintech · · Score: 1

      Performance wise (this may surprise people who haven't spent time thinking about it) Oh, I have. To get rid of the performance bottlenecks of using a hard disk, I put my pagefile on a ramdrive...

    9. Re:Pre-emptive swapping... by KinkyClown · · Score: 1

      I have 1 GB of RAM, my Ubuntu never swaps. I guess I do not use that much memory (although I develop software in Java...) under windows I discovered it keeps using my swap file. Thats why I currently use the following rule of thumb: Linux: 25% of memory as swap space, Windows: 100% of memory as STATIC (min and max the same size) swap file. But that's just how I use my OSsses. I game under Windows and I develop software, surf and read my mail under Linux.

    10. Re:Pre-emptive swapping... by nasch · · Score: 1
      This is actually a vast minority of systems in the world
      A vast minority? Wow, think how big the majority is, then.
    11. Re:Pre-emptive swapping... by Anonymous Coward · · Score: 1, Interesting

      Go get OO smart cache. You need to go get their defrag anyways since the windows included one doesn't work. It will let you limit your filesystem cache size, as well as make some registry edits for you, like turning off DOS compatable filename creation, and storing access times, which can speed up filesystem use.

    12. Re:Pre-emptive swapping... by bugbbq05 · · Score: 0

      Quick question: I've got an older notebook with 384MB RAM (max'ed out) but it has a MMC/SD Card reader built-in. If I dropped a 1 or 2GB MMC/SD Card in the slot could I tell Windows (or Linux) to move the swap file to that? Would that speed things up and increase battery life...?

    13. Re:Pre-emptive swapping... by Duhavid · · Score: 1

      I put mine on my USB drive.

      Dont let them tell you you cant take it with you.

      --
      emt 377 emt 4
  27. Enough? by AJWM · · Score: 1

    What is this "enough memory" of which you speak?

    Oh, wait, virtual memory. I thought you were talking about real memory.

    Never mind.

    --
    -- Alastair
  28. No swap at all by DrZaius · · Score: 3, Interesting

    I think it was one of the Live Journal guys at OScon that said, "If your server starts to swap, you've lost the battle".

    With all of our 64bit 4GB of ram minimum hosts floating around, there is no longer a point to having swap -- if you server really is swapping, it's under a huge load and the io is making the problem worse. Let the OS kill a few processes to get it back under control

    --
    -- DrZaius - Minister of Sciences and Protector of the Faith
    1. Re:No swap at all by georgewilliamherbert · · Score: 4, Interesting
      If the server starts to swap, you've lost the battle. But randomly killing things or locking up is losing the war.

      It's fine to set off alerts and alarms if you're paging. You should set off alerts and alarms if your servers start paging. Randomly killing things instead? Insanity.

      You can never build reliable services for users/customers unless you can handle random or accidental error conditions gracefully. Swap space is a cheap and easy key way to do that.

    2. Re:No swap at all by Rufus211 · · Score: 1
      If your server starts to swap, you've lost the battle

      Not necesarally. A smart pre-emptive swapper can swap out things even if you have 50% free memory. If some amount of memory is only accessed extremely rarely (how often does '/sbin/getty 38400 tty2' really get used, or if a program starts leaking memory) the swapper can stick it on disk. Now this dead block of memory can be used for more cache, which is always a good thing.
    3. Re:No swap at all by Salamander · · Score: 1

      Unfortunately, on many OSes (e.g. the older version of Linux we're forced to use at work) it's nearly impossible to distinguish swapping that might indicate a problem from swapping that merely indicates plain old file-cache creep. People have mentioned having more limits on swap aggressiveness, but without similar controls on file-cache aggressiveness that loses much of its utility.

      --
      Slashdot - News for Herds. Stuff that Splatters.
  29. Rules of thumb are dumb by temojen · · Score: 1

    It really does depend.

    It depends on what you're doing with the computer, and what hardware resources are available. Out of memory is bad. Very bad. On systems which have oodles of RAM, I tend to give low or no swap; on systems tight on RAM I may give 10x or more the amount of RAM.

    Here, "oodles of RAM" and "tight on RAM" are very dependant on what the system's being used for. For a home NAT gateway 64MB may be oodles; for an image processing station, 1GB may be tight (especially when dealing with medium or large format photographs).

    My desktop currently has 1GB RAM and 8GB swap, since I work with 100MPixel 16 bit images when I'm not working on hundreds of 14MPixel 16 bit images at the same time.

    1. Re:Rules of thumb are dumb by statusbar · · Score: 1

      On Linux sometimes there are surprises. On a system with 2 gigs of ram, 2 gigs of swap, I found locatedb causing huge flushes of runnable binaries into swap or whatever causing a massive system slowdown - Even though the system was normally not under any real load and no big memory allocations ever. So I shut off swap completely, and the system was consistently fast and never crashed! of course, 2 gigs was enough for what I needed. if it wasn't ... kaboom!

      --jeffk++

      --
      ipv6 is my vpn
    2. Re:Rules of thumb are dumb by Feyr · · Score: 4, Interesting

      all this swapping talk is giving me nightmares.

      a few years ago, we had a customer with multiple colocated servers complaining that sometimes they crashed for no apparent reasons.
      after much debugging, we figured out one of their script was leaking memory. eventually consuming all ram (2.5G) + all swap (1-2g).

      now the real problem is this. those were LIVE processes so the system was constantly paging back and forth, using 90%-95% cpu just to swap the damned things in and out and starving the actual processes.
      linux 2.4, linux 2.6 (early 2.6). same deal. amazingly, the distro made a difference, redhat was pure hell, debian slightly better (though still not acceptable)
      freebsd was much smarter, it just killed the offending processes.it sure wasn't ideal, but at least the server was still serving its clients

      to this day, i never put more than 256m as swap even on servers with 4G of ram. that's where we had the least problems.

    3. Re:Rules of thumb are dumb by temojen · · Score: 1

      Exactly why I don't use updatedb.

    4. Re:Rules of thumb are dumb by ookaze · · Score: 1

      Tell me exactly how your pathological problem is any indication of usefulness of swap ?

      This is plain stupid. With or without swap, you would still leak that memory, and your OS would still be at risk. The most useful thing to do would have been to limit the max amount of memory for each process, or just for the one causing these leaks.

    5. Re:Rules of thumb are dumb by Anonymous Coward · · Score: 0

      I'll try to save you some time here:

      "after much debugging, we figured out one of their script was leaking memory. eventually consuming all ram (2.5G) + all swap (1-2g)."

      Maybe in the future setup remote logging (use netconsole to get all messages), and look for 'OOM' messages in the syslog.

      Plus, use 'ulimit'.

      "now the real problem is this. those were LIVE processes so the system was constantly paging back and forth, using 90%-95% cpu just to swap the damned things in and out and starving the actual processes."

      It probably wasn't using the CPU, but it also wasn't idle, because it was in 'iowait'. Install a tool such as 'iostat' to look at disk utilization.

      Add some scripts to send you email if a machine doesn't look healthy (form another machine, use the remote logging, etc), and you'll detect memory-leaking programs quickly.

    6. Re:Rules of thumb are dumb by Feyr · · Score: 1

      there was no OOM message, it was swapping, not killing the processes. the cpu was NOT idle. and we did have "remote" debugging, but it doesnt help much when the server isn't responding (that means, the debugging tools aren't running either). see my other post about ulimit. i'll take a look at iostat though

  30. Highly dependent by Anonymous Coward · · Score: 0

    For me, my systems are highly dependent on what I do with them. Currently my swap space/file is at 0.75GB on a system with 1GB RAM. The only times that I would have encountered problems running out of memory is when dealing with Adobe's memory hogging programs. Since I'm not that big on graphics and video manipulations using those programs, I rarely run out of memory anyway.

    However, on my removable hard disks where I do general testing, I set my swap size to none. 1GB physical RAM is more than adequate for my needs.

  31. heavy windows usage = 0, anything else = default by Fry-kun · · Score: 2, Interesting

    OP poses wrong question. Virtual Memory is built into the OS and cannot be turned off. What OP means is Paging or Swap File (i.e. simulating memory using HD space). The rest of this reply will ignore this difference.

    Very simply, if you use windows and use it heavily (run some intensive tasks or need performance), turning off the page file will give you a nice performance boost.. or rather will not take away from performance.
    I have 1GiB of physical memory on my laptop, and reaching the limit in Windows when my paging file was off, posed a challenge (in other words, it worked perfectly well without it)
    This is because Windows attempts to use the paging file whenever it can (proactive), unlike Linux, which uses it only when there's no other way (reactive). Depending on the applications you're running, one of the approaches will be better than the other, though from what I've seen, I don't like what Windows does...
    Caveat Lector: this might be because I wasn't seeing the slowdowns which might've been caused by reactive approach. I've still yet to formulate an opinion on it - but so far it looks very reasonable.

    If using Linux, keep the swap partition and forget about it.
    In Windows, the best way to figure out if you need your page file is to load up as many apps as you normally load, maybe a few more - and check the memory usage (don't trust "VM usage" in windows task manager, it doesn't show you what you think it shows you!). If the usage is lower than your physical ram by a [few] hundred MiBs, turn off the page file and don't look back. If it's closer, set the page file to a small size, usually no more than 512MiB. If you set the file, make its size static, so that Windows doesn't try to adjust it all the time (it's too stupid to understand that you want to keep it as small as possible)

    Interesting to note that the paging file is not used for hibernation, even though you'd think it were almost tailor-made for that purpose. I've heard that early betas of Windows 2000 woke up from hibernation in a few seconds - I bet they were using the paging file for hibernation then... but I digress

    HTH

    --
    Did you know that "FTW" ("for the win") is a direct translation of "Sieg Heil"?
  32. None! by vio · · Score: 1

    I gotta agree with what many have already said... monitor your usage for a while, and then adjust accordingly. I haven't had a swap file in over a year in any of my desktops/workstations (1-2GB of RAM) and with prices of RAM nowadays I don't forsee myself ever needing another swap file again. ... and killing that swap file is sooooo liberating :-)

  33. But more on topic... by Junta · · Score: 4, Insightful

    My strategy generally is to use a file for swap rather than a partition, even in linux. I figure that if memory has to be swapped in from disk, it's already crappy going to disk so the extra overhead doesn't matter much, and I have freedom to adjust it up or down depending on my needs. (This is a desktop/laptop circumnstance). I generally start at 512MB or so, increasing maybe if IO is faster on the drive. I view swap like a rumble strip on a road before a stop sign. With no swap, you don't realize a process leaked memory until it's too late, with swap, while it eats through your swap the performance will degrade and you'll see the end coming ahead of time, and may be able to head it off with a kill. It may be well an good your 4GB of ram is technically capable of handling the same load your 1GB RAM+1GB swap handled in the past, but having some noticable impact when things start going wroing is nice. I realize theoretically there are better approaches, but nothing gets in your face like poor performance and tons of disk accesses.

    On a production server or a problematic system where I want support and the OS likes to dump a core to swap, I'll ensure a generous swap partition is available (generally observed active swapx1.5+physical memory size). In this case a file-backed swap may depend on layers of the kernel that are in an invalid state, and a swap partition is more likely to be reliably writable. The only system I would even theoretically hibernate on is my laptop, and I only ever suspend to ram or shutdown completely, so I don't consider my laptop as needing a swap partition of any significant size.

    --
    XML is like violence. If it doesn't solve the problem, use more.
    1. Re:But more on topic... by Anonymous Coward · · Score: 0

      umm.. resizing - use LVM

      don't come anywhere near my production servers with your so-called "partitioning schemes"

  34. Virtually none by JBob-S · · Score: 1

    "Memory is like an orgasm. It's a lot better if you don't have to fake it." -- Seymour Cray, on virtual memory.

    This is even more true today, with memory speeds growing faster than disk speeds. Don't use virtual memory for anything that is actually used more than once. I was recently asked to bump the swap on a 128G machine to 1X; imagine how long it would take to access all that memory only once, let alone multiple passes. That machine has a 1-2G swap. Any process that actively used more than 128G wouldn't finish in the lifetime of the project anyway.

    It may make sense to enable a lot of swap if you're running Linux and turn off memory overcommit. This is "unused" memory that's required because many programs only run efficiently with overcommit turned on, and you don't lose performance because the memory is never addressed anyway.

    Swap in any case should be based on memory size alone only for special purposes like suspend; otherwise, use the largest image you expect minus physical RAM.

  35. You are thinking of "thrashing." by Ivan+Matveich · · Score: 1

    Swap devices are intended to hold long-inactive pages, like those of a stopped process. They are NOT "virtual memory."

  36. Think About The Future + More by alchemist68 · · Score: 1

    Memory usage depends on what YOU are using your computer for and the platform. I have an Apple PowerMac G5 with dual 2.7 GHz PowerPC G5 processors and 2.5 GB of RAM and IT ISN'T ENOUGH! Mac OS X pages out to virtual memory almost every day, because I'm constantly using Mozilla Firefox, Apple's Mail program, Micrsoft Office, OpenOffice (under X11), iTunes, MacTheRipper, HandBrake, Google Earth, VueScan, Preview, Adobe Reader, iCal, AddressBook, iWeb, QuickTime, AOL Instant Messenger, Skype, VLC, DVD2OneX2, Toast 6 Titanium, RBrowser, iPhoto, iMovie, iDVD, and iChat. If you have a Macintosh running under a recent Mac OS X, you'll want as much RAM as possible to avoid paging-out to virtual memory - makes your Mac faster overall.

    1. Re:Think About The Future + More by LFS.Morpheus · · Score: 1

      Wow, constantly using all those apps! You're quite the Word-document-editing-(twice)-music-listening-web- page-making-dvd-ripping-and-burning-earth-browsing -pdf-reading-(twice)-calendar-browsing-contact-sea rching-video-watching-(twice)-instant-messaging-(t wice)-voice-chatting-photo-viewing-and-scanning-vo d-casting-file-transferring-web-surfing-email-send ing power user!

      Do yourself (and your Mac) a favor and command-Q every once in a while, eh?

      --
      The space unintentionally left unblank.
    2. Re:Think About The Future + More by alchemist68 · · Score: 1

      Do yourself (and your Mac) a favor and command-Q every once in a while, eh?

      What I was inferring, and based on your reply you don't seem to be quick at catching on to things, is that I use most of these applications at least once in the evening or Saturday and Sunday without turning-off the computer. Memory will get paged-out to the hard drive because Mac OS X still keeps quit-applications in memory to be launched again without accessing the hard drive. See? You LEARNED something new from this post. The only way to get around this AFAIK is to reboot.

    3. Re:Think About The Future + More by jawtheshark · · Score: 1

      I've used a Mac for a while and I was horribly confused about how swap works on a Unix machine. Then I installed Bernhard Baehrs Memory Monitor and actually *read* the helpfile. It will teach you about wired, active, inactive and free memory. What you describe is "inactive memory", and it will be used when the machine required more memory and no "free memory" is there. It's an interesting read, and using the above mentioned tool you can keep an eye on it.

      --
      Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
  37. Equal by Anonymous Coward · · Score: 0

    If the computer has a lot of memory (1GB+) I usually set the swap partition to the same size as the memory. Works great for me.

  38. Disk seek times haven't improved much by pyite69 · · Score: 1

    A machine with 9ms seek times and 4G of swap in use is probably going to be unusable. Everyone seems to over-engineer swap space a little too much, 2x the amount of memory you have isn't a bad rule unless you have a very unusual situation.

  39. old discussion by Anonymous Coward · · Score: 1, Informative

    There's an old discussion amongst various kernel developers about this issue which, even though it's a couple of years old, is almost certainly going to be more insightful than anything you'll read on slashdot. You'll note that there doesn't seem to be a ready consensus even amongst the folks who know this stuff best, so if you see anyone posting the "correct" answer, call bullshit.

    My advice is that you should just do the same thing as some random poster on slashdot who says "these days I set up my swap like blah blah blah" without any explanation or justification.

  40. hibernation in windows by sankekur · · Score: 1

    windows 2000, xp, and server 2003, do not use the swap file for hibernation, they use a file called "hiberfil.sys" in the root of the system volume. it is equal in size to the memory in the computer.

  41. Eliminate Swap! by SkyLord · · Score: 1

    On Larger systems, where the system and applications can be tuned to operate within a performance envelope, I think swap should be eliminated. It's a legacy concept, and will drag down any system if it has to operate in swap actively.

    If the system is small and resources are scarce, then swap is needed, but I would still think the best solution would be to get a new system or expand resources to accomodate. Just piling on swap to handle an application that is overrunning RAM is like trying to put out a fire by throwing logs on it.

    Personal Note: The fact that large database vendors can recommend 1x to 2x swap to RAM on large systems that have upwards of 256G of RAM is ludicrous.

    --
    Me - Professional Computer Geek
  42. Back in Windows 9x days there were tricks. by The+MAZZTer · · Score: 1

    Specifically, you could set your swap file to a FIXED SIZE to keep Windows from resizing the swap file, thus theoretically upping performance due to less disk activity.

    Today in XP, I set a decent minimum size (1.5GB, to complement my 1.5GB memory... I had 0.5GB at one point and I haven't changed my virtual memory size since then, no real need to.) and then set the maximum as high as it can go, for emergencies (memory leak from hell). 32bit Windows XP allows 3gb maximum size (so it tells me), so that's what I have it set at.

    Another old trick that works as well today is, if you have multiple hard drives, move your paging file to the non-Windows drive. So I have my C: drive set to no paging, and D: set to 1536-3072 (Windows recommends 2302 for it, fyi).

    Unfortunately I have no clue if it actually produces measurable benefits, and I have no motivation to do benchmarking to see. For most people it's probably just best to leave it be at "System managed size" unless you know what you're doing.

  43. 4GB RAM, 4GB swap by Agelmar · · Score: 3, Insightful

    I have 4GB of physical ram (ddr2-6400) and 4gb of swap. There are actually a few reasons for this, YMMV (obviously I think the answer to this question depends on what you do).

    I have a lot of things running which, usually, are doing nothing. For instance, apache2, mysql, postfix, and courier-imapd-ssl are always running, but they're rarely actually *doing* anything. (If I get a hit or an email, it's relatively rare as I hardly have very little hosted off of my home box - nevertheless, I do want these running). So I'm happy to let these get swapped out. When I start up matlab, and start dealing with huge datasets, I know it's going to swap most of these out. That's good. It will also swap out some of my matlab data that's loaded but not currently being used (and yes, it's quite possible to have >4gb in your workspace). For me, I have the swap because I need it. Figure out what you need, and you will have the answer to your question.

  44. Depends of if CPUS are Hot swappable by markk · · Score: 2, Informative

    This depends - see other comments for most situations. However if you have a large Sun, HP, Fujitsu, IBM, etc. with 16+ CPUs and say 2 to 8 Gb per CPU (not uncommon in the big systems), then at minimum you need 3 times the --per CPU-- memory, becuse if one of the CPU's goes bad, the hot swap mechanism is going to use the swap space to keep the processes (at least on some of these systems) for moving them to the other CPU's as it marks the one as bad. You certainly don't need 2 times the total memory, or several hundred Gig. This is assuming the kind of NUMA architechure that I think all of these systems still have.
    Generally we just used to use, say, 36 Gig local drives as (mirrored) swap for simplicity. In this environment you are probably on a SAN and people will say to move everything there, and that might be more true now than a year or two ago.

  45. As always, it depends by cookd · · Score: 1

    You need to add physical memory until your performance is adequate.

    You need to add swap until you have enough. You have enough if you don't run out of (virtual) memory while doing whatever you need to do with the system.

    On my main (fast) system, I have a lot of physical memory. I have about 1.5X that much swap set up, because occasionally I load a lot of programs at once.

    On a test (slow) system, I have very little physical memory. I have about 10X that much swap set up, because I still need to run programs that allocate a lot of memory, but their working set tends to stay small, so they run ok even when 90% is in swap.

    --
    Time flies like an arrow. Fruit flies like a banana.
  46. size of a core dump by Anonymous Coward · · Score: 0

    The size of swap should be large enough to hold the contents of kernel memory when a panic+core dump occurs. Anything larger than that depends on workload.

  47. The way I use swap by Thaidog · · Score: 2, Interesting

    Many people think that you should save the fastest part of the HD to allocate as swap. But after thinking about it no matter where your swap is on a hard disk it's going to be noticeable when the system pages. what is not noticeable is the perceived difference in human terms of the VM at the outer most of the platter or the innermost. And if your allocating a gig of VM or more you're wasting space for system files or applications files where things like time to boot and application launch speed can be faster. (Along with prefetch data) In Linux you can use riser for your system root to further optimize this since most system application files are small in size. (Along with a small block allocation size.) Also, if you're using a secure VM file you may notice a difference if you move the paging file to a secondary drive with the file allocated at the outermost section. No matter what the system I make a page file. If it needs to be secure you should lock the applications pages to ram memory. I any event when using a disk you're going to notice paging and at that point you'll be waiting anyway... I doubt you'll care or notice at that point the page finsihed 2ms faster or not.

    --

    ||| I still can't believe Parkay's not butter.

  48. Swap memory should not be used normally by Aaron+W.+LaFramboise · · Score: 1

    The main purpose of swap memory in a modern computer is to create an alternative to crashing when physical memory is exhausted. Swapping pages out, in the absense of a low memory condition, will probably not yield a significant improvement, and will definitely cause a significant performance penalty when those pages need to be swapped back in. The only time you want to pre-emptively swap is when you are certain a page will never be needed to be retreived quickly, which is a fairly difficult thing to determine. A secondary purpose for swap is for software suspend or hibernate. Sizing your swap to the minimum required for suspend is important, if you want to use this feature. The best arrangement is where the operating system can manage the swap size on its own. However, it really hardly matters, as you should never have more active pages than the amount of physical memory on the system. If this happens to you, the solution is to get more RAM, not more swap.

  49. Free the Swappie! by Anonymous Coward · · Score: 0

    On Linux servers I typically don't give more than 2 gigs, no matter what the memory. I even have a 56 gig box with only a 2 gig swap. The rationale is that swap is slow. If I get to the point that I need to swap 2 gigs on a regular basis, it means I need more memory. If you are maxing out your swap under Linux, don't increase your swap, get more memory! A server that is swapping consistently is thrashing...give the lil' fella a break...

    Free the Swappie!

    (on the flip side, a really old box can benifit from a larger swap since it may not have the memory on hand to load a modern Linux desktop and such completely in memory...but as above, more real memory would be better if its an option)

  50. 512 Megs.. by IlliniECE · · Score: 1

    512 MB ought to be enough for anybody... oh wait

  51. $ ls -l /var/vm/swap* by Anonymous Coward · · Score: 0
    $ ls -l /var/vm/swap*
    -rw------T 1 root wheel 67108864 Aug 29 21:35 /var/vm/swapfile0

    64 megabytes. Oh, and according to top, I have 0 pageouts.

    Mac OS X 10.4 w/ 1GB RAM if any were wondering...

    1. Re:$ ls -l /var/vm/swap* by Anonymous Coward · · Score: 0

      Wow, dude, what are you not running? 10.4.7, 2GB 17" G4 powerbook:

      $ du -h vm
      2.2G vm

    2. Re:$ ls -l /var/vm/swap* by clarkcox3 · · Score: 1

      MacOSX doesn't use a fixed swap size, it grows and shrinks as needed.

      --
      There are no tiger attacks in my area and it's all because this rock I'm holding keeps the tigers away.
    3. Re:$ ls -l /var/vm/swap* by Anonymous Coward · · Score: 0

      Your 2GB 17" G4 powerbook has a sleep image in the /vm directory. That isn't swap. That's where it writes the entire contents of your memory when your book goes to sleep (to conserve power by not keeping the RAM alive). You have 2GB mem, so you'll have a 2GB file. If you never put it to sleep, it'll never get used, but it's still set aside there when you boot, regardless.

  52. You think like a dinosaur by irritating+environme · · Score: 3, Interesting

    Sure when you had 128MB of ram, and you had a 256MB swap.

    But dude, my next box will have two GIGABYTES of RAM!

    Every one of your usage options assumes you'll run out of physical ram. Maybe if the OS is wasting it on pointless disk caching, but don't you think the programs in memory should have priority over blind disk caching?

    Lest a foolish reader believe your two options (swap immediately, or swap as lazily/late as you can) are the only two possibilities, how about swapping when, say, only 20% of physical RAM is left? That way my Firefox and Eclipse don't swap to disk and take twenty seconds to swap in when I have 500MB of GODDAMN FREE RAM!

    --


    Hey, I'm just your average shit and piss factory.
    1. Re:You think like a dinosaur by Synonymous+Bosch · · Score: 0, Redundant
      But dude, my next box will have two GIGABYTES of RAM!

      This means you'll never need swap space again?

      If your applications are taking 20 seconds to 'swap in' i suggest you buy faster storage/system bandwidth (bus/cpu), not more memory.

      I also suggest you learn some manners if you want to be taken seriously in any sensible discussion.

    2. Re:You think like a dinosaur by imsabbel · · Score: 1

      Maybe he uses mozilla...

      --
      HI O WISE PRINCE. WHT TOOK U SO DAM LONG?
    3. Re:You think like a dinosaur by NekoXP · · Score: 1

      I seem to recall that Linux swsusp2 uses the swap file as standby/hibernation space; in this case you should have enough swap space to store the compressed memory image (gzip loves to say it can compress to about 1/3 of the filesize, so I guess make it 1/2 your memory even if you have 2GB. You will need it to suspend, if nothing else, and can turn down the swap behaviour using kernel tunables.

      By the way when an application loads it probably is pushed in via mmap and therefore isn't much different from loading it from swap anyway.

      Most swap access on most systems is pre-emptive, so that the system performance balances out.
      Stuff that isn't used much goes into swap, and until reallocated stays in physical memory anyway. As soon as you need that memory, it doesn't need to swap out those pages. That's why Windows is always clacking at your disk while idle. Also; Linux allocates the vast majority of truly free physical memory to disk cache anyway (unused memory is wasted memory) so in the process of resizing caches and giving memory back, doing disk writes to flush that disk cache, you also get clacking of your disk for that.

      Seriously, you can't think using the disk is a bad thing? Just wait for those new NVRAM drives, swap will have never been faster.

      On a lighter note, for 32-bit systems who don't want the overhead of PAE for main processes, there are methods to map the >4GB range and use Northbridge DMA to activate this RAM (maybe up to 60GB if you're insane) as a virtual swap disk. Imagine swap that's just as fast as RAM, with only the overhead of a context switch into the extended page map.. that would be neat. I wonder why nobody every implemented this in Linux for PAE (or PowerPC goddamn it!) systems :(

    4. Re:You think like a dinosaur by BrokenHalo · · Score: 1

      I also suggest you learn some manners if you want to be taken seriously in any sensible discussion.

      You're new here, aren't you?

      ;-)

  53. Mac OS X swap by atomm1024 · · Score: 4, Informative

    On Mac OS X, swap is stored (by default) in files in the /var/vm directory on the boot hard drive, instead of on a separate partition. So there's no limit to how much is used, nor a predefined minimum amount of space used, the swap space expanding and contracting as needed. That seems reasonable.

    --
    Signature.
    1. Re:Mac OS X swap by Anonymous Coward · · Score: 1, Informative

      Read here about moving swapfiles on Tiger (or Panther).

    2. Re:Mac OS X swap by Anonymous Coward · · Score: 0
      Change the line in CONFIG.SYS:

      SWAPPATH=:\

      is how much free space is left before the OS alerts you to running out of swap space.

      is the initial swapsize

      Example: SWAPPATH=C:\OS2\SWAPPER.DAT 4096 12880

      4MB minfree, 12MB initial swapsize.

      You can even swap to a RAM disk, see this page

      To turn off swapping, in CONFIG.SYS, use the line MEMMAN=NOSWAP,PROTECT

    3. Re:Mac OS X swap by Anonymous Coward · · Score: 0, Funny

      As an Apple fanboi, I'm surprised you'd even know what a swap file is. I was thinking that, like all the other fanbois out there, you were too busy jerking off to your Steve Jobs screensaver.

    4. Re:Mac OS X swap by Anonymous Coward · · Score: 2, Informative

      So there's no limit to how much is used, nor a predefined minimum amount of space used, the swap space expanding and contracting as needed. That seems reasonable.

      I hope that there is some upper limit on how much is used! It's bad enough when a memory-leaky process uses up all of your RAM, but all of your hard-drive space too (in the form of swap)? Yeesh!

  54. Only punks use swap by utahmindtrick · · Score: 1

    With modern systems easily capable of alot more than pitiful 2GB (which is the minimum for anything respectable) if you need swap (or Virtual Memory) then you need more RAM. Simple, RAM fast, HD slow, swapping in and out of HD nasty retarded slow. Swap is a bunch of sissy pansy bullshit. Be a man, load up with RAM....more power.....

  55. If you don't use 3D by Anonymous Coward · · Score: 0

    http://www.linuxnews.pl/_news/2002/09/03/_long/144 5.html describes a way to use gpu memory as swap on linux.

  56. BSDs like more by Just+Some+Guy · · Score: 4, Insightful
    According to FreeBSD's tuning(7) man page:
    The kernel's VM paging algorithms are tuned to perform best when there is at least 2x swap versus main memory. Configuring too little swap can lead to inefficiencies in the VM page scanning code as well as create issues later on if you add more memory to your machine.

    Disk is always far cheaper and more plentiful than memory. If you have four gigs of memory, what's wrong with carving eight gigs of swap out of your terrabyte RAID? If you have that much memory in the first place, then you're probably running large apps. Do you and them a favor and give them a little breathing room.

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:BSDs like more by archen · · Score: 1

      While disk is always cheaper than memory, I've found that memory has itself become cheap enough to negate adding more swap. Most servers I buy I account for a bit more RAM than normal, only I've found that even base configurations actually have more RAM that is really utilized by the server. For most of us, it's just as easy to spend a bit more money and pile on RAM if swap really becomes an issue.

      There is also some obscure place that (at least as of FreeBSD 5x) a minimum of 256Mb of swap should be allocated. My rule of thumb is 256Mb minimum. 2x until 512Mb of RAM. Then just use 1Gb of swap. Really if performace is needed, then thinking about how long it's going to take a server to actually access and suck 1Gb back and forth into memory isn't going to gain you a whole lot I would think.

  57. Swap by Ice+Wewe · · Score: 1

    I have a Corsair XMS 2GB kit in my AMD64... The motherboard can hold 4GB. I have 4GB Swap. Set swap to whatever the maximum capacity of your computer is, and you'll be fine. I use swap all the time, even with 2GB, Ubuntu dual head + wine + windows games + firefox 40 tabs + thunderbird + amsn + xosview + gimp, eat up a lot of RAM. So yeah, 2GB isn't enough. Someone send me 4!

    1. Re:Swap by JustNiz · · Score: 1

      >> Set swap to whatever the maximum capacity of your computer is, and you'll be fine.

      Uhh how did you come up with that logic? its entirely down to what you use your PC for.
      I'm surprised with 4GB ram you actually need to use swap at all, but maybe you're a graphic artist working on very hi-res pics or soemthing.

    2. Re:Swap by Ice+Wewe · · Score: 1
      I don't have 4GB of RAM. Either you mis-interpreted, or I explained it wrong. Set your swap to the maximum capacity of your computer's motherboard and BIOS. (ie. How many sticks of RAM you can put into the slots on your motherboard. How much the BIOS will accept.) That way, even if you stock the computer with as much RAM as it'll hold, you'll have an equal amount of swap. I have 2GB of RAM, and 4GB of swap. I do run out of 2GB of RAM, often. It happens when you run a dual display setup, with 2 20 tab firefox windows open, thunderbird for email, aMSN for chatting, GIMP for photo editing, xmms, and you don't quit any of those applicaitons when you play windows games through emulation.

      Example: My motherboard, Biostar TForce939, has 4 DDR400 RAM slots (for a total capacity of 4GB, of either unbuffered or ECC DDR400 RAM). For the past 7 months, I've been running on a single 1GB Corsair value select stick of RAM, yet I had 4GB of swap. Then I bought a Corsair XMS 2GB kit (2 matched 1GB sticks), so that I'd have double the bandwidth to memory (see Dual Channel). This was to improve poor performence in games, and to speed up overall system performence. The memory bandwidth (as measured by memtest86) went from 1500MB/s to over 3000MB/s, which is a 2x increase. It did speed things up, considerably.

      The wikipedia article is almost correct. The one thing I'd like to point out is that AMD has for a long time, integrated the memory controller into the CPU. This way there would only be one memory controller, since Intel CPUs use a memory controller in the chipset. This means the CPU can directly access the memory, without having to go though the Front Side Bus (FSB).

      --End rambling.

  58. Enough not to run out by tmh+-+The+Mad+Hacker · · Score: 1

    If your system informs you that you ran out of memory, then you apparently didn't have enough for what you were doing. If you have never received such an error, then I'd say you have plenty...

  59. Big Hard Drives... by ajaf · · Score: 1

    or you could ask... How much hard disk space do you use for your swap partition today?

    --
    ajf
  60. your next box needs swap by r00t · · Score: 4, Funny

    You have a GUI to run: 600 MB for firefox, 1800 MB for OpenOffice.org, 100 MB for X, 100 MB for desktop odds and ends, 300 MB for Evolution or Thunderbird, and 10 MB for old-style stuff running in the background.

    Total: 2910 MB

    Yep, you need a gigabyte of swap. OpenOffice.org was made 64-bit clean for a reason. If you plan ahead, not wanting to reallocate disk space in the next few years, you'll allow for this:

    2 GB for firefox, 5 GB for OpenOffice.org, 1/2 GB for X, 1/2 GB for desktop odds and ends, 1 GB for Evolution or Thunderbird, and 10 MB for old-style stuff running in the background

    That's 9.01 GB. You're exactly 7.01 GB short, so you'll be needing that swap space before you know it.

    1. Re:your next box needs swap by CyberBill · · Score: 1

      What the hell are you doing in firefox to require 600MB of RAM? And nearly two -GIGABYTES- of RAM for OpenOffice???

      I currently have 5 firefox windows open and its pulling a massive 40MB of RAM. My current peak amount of RAM in use is under 400MB. Thats running WindowsXP, lots of firefox windows, Visual Studio.NET, DAEMON tools, Symantec AntiVirus, etc.

      --
      -Bill
    2. Re:your next box needs swap by Anonymovs+Coward · · Score: 1, Insightful

      2 GB for firefox, 5 GB for OpenOffice.org, 1/2 GB for X, 1/2 GB for desktop odds and ends, 1 GB for Evolution or Thunderbird, and 10 MB for old-style stuff running in the background
      If you're using "top" to get those numbers, you've probablygot them wrong. They definitely look wrong.
    3. Re:your next box needs swap by EvanED · · Score: 2, Informative

      Did you set the options in Firefox that disable caching of back pages? It by default stores (I think) prerendered pages (or at least a representation a lot closer to a rendered page than the HTML) in RAM so if you hit back it can come up nearly instantly. Before I turned that off, I'd have to restart Firefox every couple days because it would start to eat up so much RAM. The processes tab in task manager would tell me that it would routinely use several hundred megs. I have a post in my LiveJournal where I complain that it was using 700 MB.

      Heck, even with that option turned off, it says the mem usage is at 210MB now. That's with 17 tabs in three windows open.

    4. Re:your next box needs swap by NormalVisual · · Score: 2, Funny

      What the hell are you doing in firefox to require 600MB of RAM?

      Double clicking on its desktop icon? :-) Seriously, it's not nearly as bad as it was, but Firefox does like to put a big helping of RAM on its plate. Right now I have four tabs open with mostly text content on each, and FF is eating about 100 MB.

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    5. Re:your next box needs swap by r00t · · Score: 1

      Typical: active web browsing, a few dozen windows open (tabs are for OSes without virtual desktops), and an uptime of about a month.

      At that point I restart it, or the OS kills the damn thing for being too much of a hog. I have no doubt that firefox would consume infinite memory if this were possible.

      Year by year, the software grows. Plan for regular desktop apps that consume multiple gigabytes. Some of the latest apps are even written in Python, C#, and Java. (less leaky perhaps, but the data structures are not even remotely lean)

    6. Re:your next box needs swap by Anonymous Coward · · Score: 0

      Could you please tell us where you got those ridiculously large numbers from?

    7. Re:your next box needs swap by Anonymous Coward · · Score: 0

      If OpenOffice.org is 64-bit clean, why do all Linux distributions package it as one of the only 32-bit applications in the AMD64 versions? It's certainly not because there's widely used binary only plugins that wouldn't work with a 64-bit build (as with things like Firefox). It's a pig with regards to memory use, but it's not that bad when editing any document I've tried. I don't think I've ever managed to push Firefox much above 150-200MB too, usually it hangs around 40-60.

    8. Re:your next box needs swap by Anonymous Coward · · Score: 0

      I've modded the parent post funny. You guys can stop taking it seriously now.

    9. Re:your next box needs swap by Rakshasa+Taisab · · Score: 3, Funny

      And if you were using "grep" to try finding the irony in the post, you probably didn't get any matches.

      --
      - These characters were randomly selected.
    10. Re:your next box needs swap by SkunkPussy · · Score: 1

      How come the GP post is modded insightful +1 while parent isn't modded at all! Parent should be +1 funny and the GP should be -1 redundant.

      --
      SURELY NOT!!!!!
  61. Depends on your OS, system and needs by Sycraft-fu · · Score: 1

    While you can turn it off for large memory systems as some suggest, that's a bad idea. I'm sure you never think you'll eat up 2GB of RAM but it can be done. I'm known to run my system out of RAM from time to time on accident.

    So, here's how I'd break it down:

    --If you have less than 512MB RAM, get more RAM dammit.
    --If you have 1GB of RAM go for a 1-1.5GB swap. That's enough you shouldn't run out but not too much.
    --If you have more than 1.5GB and are on a 32-bit platform, then set the swap to make up the difference to 4GB. That's all your system can address anyhow. Yes I know there's stuff like Intel's PAE and such but really, on a 32-bit system 4GB is all you ever really have and all you should ever count on.
    --If you have a 64-bit system with 2GB or more RAM, I'd probably go for them RAM amount over again. So 3GB of RAM, go 3GB of swap. That basically lets the OS swap out your entire memory, should it need to. Overkill really, but disk space is cheap.

    All in all in high memory (2+GB) situations it's non-critical.

    In the case of Windows 32-bit, much past 2GB isn't likely to see a lot of use. Windows divides it's virtual memory model as 2GB user, 2GB kernel. Well if you actually HAVE 4GB of RAM, you'll find that a single program just can't access more than 2GB of it, the address psace presented to it won't allow that. So really unless you are running multiple massive memory apps, you aren't going to accomplish anything. In 64-bit, of course, it'll support what you give it.

    1. Re:Depends on your OS, system and needs by DudemanX · · Score: 1

      In 32-bit Windows you can add the switch /3GB to the boot.ini file and it will allow 3GB to be allocated to programs instead of 2GB.

      For the record I have 4GB and disabled the page file.

    2. Re:Depends on your OS, system and needs by Sycraft-fu · · Score: 1

      The problem is the program must still be 3GB aware. Programs are usually designed assuming the 2GB limitation. You are corret that there are programs out there that can use all 3GB of user memory, when enabled, but it's not all of them. My recommendation when you have 32-bit Windows is just act like you have 2GB of RAM. The extra won't be completely worthless or anything, espically not for multiple apps, but essentially treat your apps as though there's a 2GB limit and you won't run in to trouble.

      As a practical matter outside of high intensity stuff like rendering, EM wave simulation, large sample synthesis, and other such pro apps, it's pretty hard to hit that limit.

  62. 1 gig+ turn it off by HaMMeReD3 · · Score: 1

    I doubt that you'll ever break the 1 gig mark, with 2 gigs of ram, it's pretty safe to turn the virtual memory and swapping on windows off through the control panel.

    I've had my swap turned off ever since I got my first gig of ram.

    If you are doing something so memory intensive that you might need to swap, good software all has it's own swap built in, e.g. photoshop will swap itself when necessary.

    To know for sure if you need to use swap or not, hit ctrl-alt-del, and look at the commit charge in the task manager, if you've ran your computer for a while and the peak is the amount of ram you have, it should be safe to turn the swap off. My computers peak is at 700megs, and I run 2 virtual machines, photoshop, eclipse, and stream video all at the same time. So it's probably pretty safe.

    1. Re:1 gig+ turn it off by Anonymous Coward · · Score: 0

      Good move HaMMeReD3. That's what I did too.

      Pre-emptive swapping is stupid when it's not necessary. If windows was more intelligent, it would not use pre-emptive swapping unless the user's peak memory consumption frequently exceeds the available RAM on the system.
      My computer was thrashing to a halt every time I switched applications, even though I was using no where near a gig of memory, so I eliminated the VM paging file. Problem solved.

  63. Virtual what ? by kabz · · Score: 0, Offtopic

    How much WHAT ?!?!?!?

    (I use a Mac you insensitive clod!!)

    Ohhhhh, /etc/fstab ...

    --
    -- "It's not stalking if you're married!" My Wife.
    1. Re:Virtual what ? by yoyhed · · Score: 1

      Before OS X, I remember Macs calling it virtual memory as well.

      --
      WHO NEEDS SHIFT WHEN YOU HAVE CAPSLOCK/ DAMN1
    2. Re:Virtual what ? by Fordiman · · Score: 1

      Yeah. They're unix now, right? So is it swap?

      --
      110100 1101000 1101000 1100110 0 1101111 1101000 1100011 1
    3. Re:Virtual what ? by escher · · Score: 1

      It's a virtual swap memory space partition drive mount! VSMSPDM Forever!

    4. Re:Virtual what ? by mcmaddog · · Score: 1

      michaels-pb-g4:~ mcmaddog$ cat /etc/fstab.hd
      IGNORE THIS FILE.
      This file does nothing, contains no useful data, and might go away in
      future releases. Do not depend on this file or its contents.
      michaels-pb-g4:~ mcmaddog$

    5. Re:Virtual what ? by ktappe · · Score: 1
      (I use a Mac you insensitive clod!!)
      You might want to go poke around in /var/vm. Just please don't delete any active swaps or we'll have trouble chatting with you for a while until you reboot. :-)

      -Kurt

      --
      "We can categorically state we have not released man-eating badgers into the area." - UK military spokesman, July 2007
    6. Re:Virtual what ? by dal20402 · · Score: 2, Informative

      Power Mac G5
      OS X.4.7
      3GB physical RAM
      64MB swap file, which has never grown bigger since I added the extra RAM

      ...so, no, at least on OS X there's no point in having 6GB swap files.

  64. Swap partition, nope, swap file. by BrookHarty · · Score: 1

    Hell, I still use swapfiles, too bad most distros dont offer it as an option anymore.

    1. Re:Swap partition, nope, swap file. by Gothmolly · · Score: 1

      Hell, its still possible to create one yourself. If you know enough about swap to use a file, surely you can use the 'mkswap' command.

      --
      I want to delete my account but Slashdot doesn't allow it.
  65. In soviet russia.... by Anonymous Coward · · Score: 0

    ...memory swaps YOU!

  66. Rule of thumb... by tachyonflow · · Score: 4, Insightful

    But... but... the rule of thumb says to have twice as much swap as RAM!

    It's a pet peeve of mine that so many system administrators appeal to "rules of thumb" about decisions such as this, instead of actually thinking it through. Sys admins pass around these nuggets of wisdom with unquestioning reverence, like they were handed down from some bearded UNIX guru sitting on a mountaintop. These rules either 1) happen to reflect reality, 2) do not reflect reality, or 3) reflected reality 20 years ago but nobody got around to issuing some sort of "revocation rule of thumb". :)

    My experience is that very little swap is needed these days, and the rule of thumb falls into category #3. Long gone are the days that the OS demanded swap space for all process memory.

    If I have a machine with 1GB of RAM, I'll usually give it 512MB of swap or so. As discussed elsewhere in this thread, a little bit of swap is good for pre-emptive swapping and for emergencies (to avoid the dreaded Linux "oom killer".) Also, if you're going to use hibernate, you'll want at least as much swap as real memory.

    1. Re:Rule of thumb... by Cicero382 · · Score: 1

      DISCLAIMER: I am one of those bearded UNIX gurus (28 years experience), but I don't have a beard (Note to self - SHAVE) and I don't live on a mountain (I live in Italy in Porchiano del Monte... damn!)

      The point about "rules of thumb" is that they are just that. They are *not* a replacement for a well engineered solution.

      I've seen the role of swap space wax and wane over the years and, although its function has changed quite a bit, it still has its uses today.

      In the following text I concentrate mostly on storage capacity, not timing (then it became *really* interesting). I have also been a bit free with the technical details over time. (More detail? Finance me to write a book)

      In olden days (when a good sysadmin needed to be able to read core dumps in octal) The disparity between RAM (core) and disk space (Fastrand drum, anyone?) was *huge*; eg 2M disk, 16K RAM (about 120:1 - note this figure, it appears again, later). The other important variable was process size (text+data). In those days, programmers went to extreme lengths to reduce the load on RAM. Nonetheless, processes still managed to occupy all available RAM so mechanisms were necessary to manage the overflow. Allocating a portion of disk space was a logical solution when one could sacrifice a small percentage of disk for the ability to run larger programs. Originally these were called "overlays" which just dealt with the text part of the process (the actual program - not the data) but eventually evolved into primitive swapping which dealt with both text and data albeit on a "all or nothing" basis. The important bit is that processes regularly occupied more space than RAM could provide. In these ancient times the "swap" size was carefully calculated, often down to the last word.

      Later, both RAM and disk technology started to improve rapidly but not in parallel. RAM was catching up and the new ratio of disk:RAM was more like 50:1 or less. At the same time process size increased, but not to the same extent because programmers were still very aware of memory constraints. Usually a few processes would fit into RAM quite easily. But now real "multitasking" was available and everyone wanted to use it. Multiple processes *wouldn't* fit into RAM but it was possible to cheat by using swap to create the illusion of more RAM than there actually was. This also drove the development of "all or nothing" swapping to something called "demand paging" (BSD something or other; look it up) which tightened the granularity of disk to memory transactions and blurred the distinction between permanent disk store, swap and RAM. So, swap survived because, although RAM capacity had expanded enormously, demands on it had expanded even more. This is the time when the first "rules of thumb" appeared; and they appeared because noone really knew how the process/memory model worked. A good rule of thumb was swap should be between two and three times RAM capacity - it was rough, but it generally worked. There *were* exceptions when the ROT obviously *didn't* work so it was down to trial and error to find out what did. This was always a result of programmers designing programs that weren't really designed for the technology of the day. Some databases and design tools spring to mind here.

      Nowadays, we have an entirely new situation. Or do we?

      From high-end desktop machines to small/medium sized servers we are looking at a disk:RAM ratio of 120G:1G or 500G:4G and so on. A ratio of about 120:1 - remember that? The big difference between now and the olden days is that the *role* of these computers can differ wildly.

      One way of looking at this is that a desktop machine is simply a vastly overpowered server - the same machine could easily deal with hundreds, if not thousands, of server clients but it doesn't need to... just one user. In this case it's very unlikely that it will need to use swap because the number and scale of processes it's required to run are largely known and it's got more RAM than it will likely use. S

  67. Windows/MacOS: Let the OS decide, Linux: 2.5x by Anonymous+Freak · · Score: 1

    In Windows and Mac OS X, let the system decide. Windows likes to swap things out to keep physical memory free, so having some swap will in fact make the system less crash prone (since you won't suddenly run out of memory.) Just let the OS decide, it will enlarge and shrink as it sees fit, and you don't have to worry about it.

    In OS X, you can't really control it anyway (unless you dig into the BSD roots.) So leave it alone.

    In Linux, I generally recommend swap area equal to the time-tested 2.5x system memory. Unless you KNOW beyond a shadow of a doubt that it will be a 'light use' system, then go with swap equal to main system memory.)

    The only time I ever set swap to zero is on a hard-drive-space-lacking notebook computer that has plenty of memory. (A rare occurrence.) Although I do have a testbed machine running now with 4 GB of main RAM and an ancient 4.3 GB hard drive, so it's running with no swap. (Awaiting a new hard drive at the moment to turn it into a production machine, so it's just stress testing itself with the old hard drive.)

    --
    Another non-functioning site was "uncertainty.microsoft.com."
    The purpose of that site was not known.
  68. Again a broken summary... by Name+Anonymous · · Score: 1

    The question should be: How much swap space is enough?

    And the answer depends on a lot of things. This includes the usual questions of what programs and how many concurrently.

    And of course some Unix variants have /tmp in "memory" - so that takes up swapspace as well.

  69. My General Formula... by hcob$ · · Score: 1

    For Desktops:
    --------------
    2x physical ram, capped at 512MB
    reason: Most everything the user wants to do involves "twitch" access. By wich I mean this: If it ain't fast, it's crap. Paging to disk.... is flat out SLOW. For Servers:
    ------------------
    2x physical ram, up to (HD usable space / 10);
    reason: Servers have variable load requirements. You never know from one day to the next what your load will be.(sure you can estimate, but that goes beyond general fromulas) By having massive amounts of pageable to disk memory(in an envrionment where response time is not a big as uptime) you have the advantage of absorbing that excess work.

    --
    Cliff Claven
    K.E.G. Party Chairman
    Founding Leader of: Koncerned for Egalitarin Governance
    1. Re:My General Formula... by josepha48 · · Score: 1

      Actually that 2x still applies in certain cases. For windows that space can be used to dump the contents of memory to disk with debugging information. Essentially this creates almost a 'system core' file that someone could debug. For most desktops we don't care about that nor would we ever do that. One could nowadays use a 4Gig desktop and not use swap unless they were doing virtualization.

      --

      Only 'flamers' flame!
      Does slashdot hate my posts?

  70. What? by labratuk · · Score: 1

    Virtual memory is not the same thing as swap, you imbecile.

    --
    Malike Bamiyi wanted my assistance.
    1. Re:What? by Anonymous Coward · · Score: 0

      Uh, you're wrong. Virtual memory is swap. Swap is not page space. Maybe you, like many of the other folks here, misremembered something you read once in a DOS manual.

    2. Re:What? by labratuk · · Score: 1

      No. Read a few computer engineering books. Microsoft call swap 'Virtual Memory' in their silly dialog boxes, and hence people think the two are now synonymous. Virtual memory is 'merely' the system that anonymises memory access for a process and provides it with a private address space. Page swapping is something that can be built beneath that.

      --
      Malike Bamiyi wanted my assistance.
  71. Re:heavy windows usage = 0, anything else = defaul by thegrassyknowl · · Score: 1

    (i.e. simulating memory using HD space)

    Simulating high speed solid state random access memory using hard disk memory.

    Hard disks are memory too. Last time I put data on a hard disk it seemed to remember what I put there.

    --
    I drink to make other people interesting!
  72. How long is a piece of string? by Anonymous Coward · · Score: 0

    Plenty of good comments here already. As has been pointed out, you may get performance benefits by swapping out less-used apps and using that RAM for disk buffering instead.

    But in my opinion, for a server at least, you should have at least as much swap as physical RAM, possibly more. Why? Well, if (for example) Solaris has a kernel panic, it can be configured to dump the contents of RAM out to disk. Which disk, and where on that disk, is safe? You can't rely upon the filesystem driver being safe to use; it might be that that's what caused the panic ... so the kernel dumps everything out to the swap partition. That's fine: the kernel's just panicked, so the contents of swap are moot anyway; you know you're not overwriting anything important that way (unless you're holding serious data in /tmp, in which case you have bigger problems than wondering how large swap should be.) Ok, maybe the disk driver has caused the panic, but that's relatively unlikely; you shouldn't have swap (or root) on fancy-schmancy disks anyway.

    On the next boot, it reads the data in from the swap partition, and writes it to a nice, permanent file somewhere on the filesystem. That dump file can then be sent off to Sun for analysis (or whomever else might be interested). Effective, and above all else, safe.

    Once you have that swap space in place, you can start asking questions about whether you should allocate more. The answer to those questions depends on the applications you're running, and no one answer will be right ...

  73. Careful with how much swap you allocate. by sudog · · Score: 1

    These days it's just better to upgrade your RAM rather than going much beyond 1.5-2GB swap. Why? Well, the problem I'm seeing with enterprise and high-use database applications is that too much swap becomes extremely counter-productive for large processes or large numbers of processes. "Too much" is often unfortunately defined post-event as "the amount of swap that it takes for the OS to bring your system to its knees long enough to annoy someone important."

    In reality, it is better for these high-use users to limit swap enough that an out-of-control process or process group is halted before the system begins swapping so much as to become unusable.

    Ah, but sudog, you might be thinking: your users should just be using resource limits per-application!

    This is irrelevant, I say: if anything else ever, as a (perversely) cooperating set of processes start being pushed out to swap then we have the same problem and we're screwed again. The real solution is to limit swap, not try to juggle individual processes like a herd of cats.

    Hard drives just aren't fast enough to support a large volume of swap; think about it. The HD speeds become a significant bottleneck when swap is busy, and since swap usually takes precedence over normal drive use, your responsiveness in the machine drops to unusable levels. Normal users especially *really* don't have the drive speeds to accommodate a large swap, and it's been my experience with mid-range servers running applications heavily used by hundreds or thousands of concurrent users that even on the big servers, if you set swap too high you get exactly the same problem.

    So therefore, let me offer you my answer: calculate the speed of your drives in a MB/sec ratio. Multiply that by about 30-50 (depending on your own tolerances) and set that to be your swap.

  74. Are you using tmpfs or not? by hpa · · Score: 5, Interesting

    One thing to consider is whether or not you're using tmpfs for /tmp. For performance, I recommend using tmpfs for /tmp, and basically treat the swap partition as your /tmp partition. It may seem counterintuitive, "why would it be faster than a filesystem when it's backed to disk anyway, and my filesystems caches just file if need be?" The answer is that tmpfs never needs to worry about consistency. On the kernel.org machines, we have seen /tmp-intensive tasks run 10-100 times faster with tmpfs than with a plain filesystem. The downside, of course, is that on a reboot, tmpfs is gone.

  75. What OS are you running? by swordgeek · · Score: 1

    Honestly, all of these answers and not a single person has asked this question yet? /. may have hit a new low tonight.

    The proper answer is, 'it depends.' This is one of the things it depends on.

    --

    "People who do stupid things with hazardous materials often die." -- Jim Davidson on alt.folklore.urban
  76. windows knows better than you by Anonymous Coward · · Score: 1, Informative

    Turning off the page file in windows can be regarded as a hint that you wont need it. If you leave it turned on, windows will assume it might be needed and use it proactively to make the best use of it when it is absolutely needed.

    However, this is probably not a good hint to make. However great you think it is not to use the pagefile, youd probably rather some of that memory get used for disk io buffers than hold super ancient stale pages that nobody is accessing.

    I think the best way to look at this is the same way as the superfetchwhatever flash drive feature of vista.. obviously adding 1G of dram is better than adding 1G of flash memory, but even if you think its pointless, a lot of very intelligent people are finding ways to make the OS take advantage of whatever resources you can scrape up for it and there is plenty of room for improvement and innovation in this respect.

    Similarly, if you are choosing between 2G of page file and 2G of dram--choose the dram! But if you can't fit any more dram in, you'll wish you gave windows the extra resources it can use to tune your performance.

  77. swap bits by walshy007 · · Score: 2, Informative

    whereas linux can swap however you wish, swap partitions are only frequently used because they are the best performance wise, no overhead dealing with the filesystem. Linux can and will use basicly any type of storage you can imagine to swap on though.

    If I ever encounter a linux box without swap, a quick dd creating an empty file and then using swapon on the file fixes all, you can also use multiple swap files/partitions if necessary. same deal.

    only main annoyance with mac os vm is that it swaps out way before necessary, not as bad as windows but still it does some strange things which my mac tech friends cannot fathom why it does that way. Also it (appears) to not be changable behaviour. Correct me if wrong on that since said friends are quite annoyed with it :)

  78. swap is a bug by Geekboy(Wizard) · · Score: 1

    these days, when you hit swap your system is misconfigured.

  79. No swap at all by Venik · · Score: 1

    One of the systems I support is a Sun v1280 with 96Gb RAM (three system boards maxed out). The system primarily is a db server running Oracle 10i. I set swap at 12Gb (per Sun's recommendation). However, this box has been up for over a year and actively utilized with swap usage unchanged at just over 200Kb. Still, swap is an OS requirement (at least for Solaris 8), even if it's set to just a meg.

  80. Little to none by Jerf · · Score: 1

    150 comments as I write this and I haven't seen anybody say this yet.

    Processors have gotten faster, memory has gotten somewhat faster, hard drives have gotten monstrously larger, but hard drives have only gotten marginally faster since ten years ago.

    Instead of measuring swap in terms of absolute size, measure it in terms of time-to-fill, if you were writing flat-out, which you never are with swap.

    Let's say you have 1GB of memory and you use your rule-of-thumb for 2.5GB of swap. Using an average hard drive transfer of 50GB/sec (and I think that's actually read, not write, but as you'll see it doesn't really matter), if you're going to use that swap, it would take you nearly a minute to use that space, writing flat out. Writing's often slower so multiply by an appropriate amount.

    Odds are you're not actually going to use it that way, so whatever is using that swap is probably going to take a lot longer, orders of magnitude more.

    Do you really need a minute's worth of swap? Is there anything that is so critical that you can't afford to run out of memory, but you're willing to wait hours upon hours while the swap is fully utilized?

    Swap has two purposes: To swap out uncommonly-used pages so you can load more of the current working set, and to extend the memory space available to programs. 10 years ago, when we had mere seconds of swap, this made more sense. You could load windows, and swap half of it out, and boy did you ever need that RAM. If you were going to load a Word document that didn't quite fit, swap could save your bum, and if it got too loaded, it'd still run out of memory. You could afford to wait because you only had a few seconds of swap, and short of a really pathological swapping pattern you could expect your operation to terminate in a couple of minutes.

    The second use in modern times is basically pointless; just let the program fail. You almost certainly do not want to let the program spend the next hour swapping. The first use might still be valid, but you might as well only use a couple of seconds of swap; call it 100MB. Beyond that, nothing is really useful. And in Windows, excessive swapping also tends to basically lock up the machine which is something to be avoided.

    Huge swap partitions, unless you have another use for them (some implementations of Linux suspend are the only ones I know) are basically a holdover from the past, religiously clung to by people who have been 'doing it this way' for over a decade. Skip the swap unless you know why you shouldn't.

    1. Re:Little to none by Anonymous Coward · · Score: 0

      Swap has two purposes: To swap out uncommonly-used pages so you can load more of the current working set, and to extend the memory space available to programs.

      This is mostly true for desktop systems...

      Page space has some other purposes. For example, say you have a multi-user system that's close to capacity. If everyone accessed the system at once, it would run out of memory. The OS, realizing this, uses available page space and every time some memory page is changed, the OS writes it both to disk and to physical memory. Now say the page needs to be swapped out -- on a modern OS it's a simple matter of flipping a bit in the page table. The page is now magically on disk. The in-memory page can be immediately utilized for something else. If you didn't have page space then this couldn't happen and the system suffers.

      On desktop systems page space is also useful. Many people tend to keep applications loaded but not active. Some OSes even pre-load libraries. This is not for reasons related to the *speed* of the drive, but issues with the dynamic linker that's a requirement of modern OSes. (The link process is relatively slow). Without page space the dynamic memory process suffers... and again, has nothing to do with the speed of the disk but of the linker.

      In other words, keep the page space unless you know you shouldn't.

    2. Re:Little to none by Zoolander · · Score: 1

      If I had mod points, I'd give them to you :)
      For desktops, I don't see any need for large swap at all (maybe apart from suspend, but hey, that never works for me anyway). If you run out of RAM, you probably want the process killed anyway, instead of waiting minutes for the thing to respond (so you can kill it manually). 512MB should be enough.

      --
      Meep.
    3. Re:Little to none by Jerf · · Score: 1

      Both of your points are merely special cases of swapping out uncommonly-used pages to include more of the working set.

      Merely naming such special cases off does not constitute any extra argument that you should keep a large amount of swap around. (I already said a small amount was potentially useful, but even on a multi-user system the only way you're going to get even 10 seconds of programming code swapped out is if the system is already basically dead due to swapping.)

  81. Read (please!) by Anonymous Coward · · Score: 5, Informative

    Man, it's utterly depressing to see the same useless "rules-of-thumb" still in effect when the original question is asking if the rule-of-thumb is a good idea.

    1) Page space is not swap space. There's a small distinction that's generally lost (and generally ignored). Page space is used to move memory pages to and from disk. Swap space is technically to move entire processes out to disk. The difference is mainly based on when your OS was created (i.e., technological underpinnings) and no need to get into it now... but the difference is meaningful.

    2) Page space is not *free*. There's a misconception that if you have 500G of disk space then "how does it hurt" to put 8G of swap on 4G RAM. Depending on your OS, the size of the page table can grow remarkably depending on how much memory (RAM + VM) is allocated. This means that adding 2G of page space may not cost anything, but adding 2.5G may suddenly take up another chunk of real, non-pageable memory because the page table cannot itself be paged. This means that if your app is thrashing, then adding page space may make it worse.

    3) Even with lots of RAM, it's still often a good idea (depending on your usage) to have some page space. Modern OSes will still page out unused pages to use RAM for better stuff. I.e., if you have a huge file open in a graphics application, but are not actively using that application for a length of time (an hour, say) then the OS will page it to disk. This makes better use of your physical RAM. On some OSes the OS will use page space even if free RAM is available. It can then toggle a page out by flipping a bit in the page table and not have to do an expensive write.

    4) In some systems you can overcommit memory. Applications tend to request a lot more memory from the OS than they'll actually use. This is useful in many instances but it again depends on your usage. If you're running a single application that doesn't dynamically allocate memory then you can run pageless. If a new app requests memory that's not available then it will get a failure on malloc request. This can be desirable in some circumstances.

    5) There are benefits to running page space on a separate disk, but for the vast majority of home users, the difference is negligible. This applies to Windows and Linux. Once you start stressing the VM subsystem then a separate disk is highly desirable.

    6) You can create page files on Unix/Linux. It's not desirable generally because of the extra filesystem overhead and possibility of fragmentation. But hey, in a pinch it works.

    7) Why this 2x RAM rule? A lot of it comes from old VM subsystems that needed a "picture" of the entire memory space. This made the page-out algorithms easier to code. Newer algorithms don't require the 2X RAM.

    KL

    1. Re:Read (please!) by CTho9305 · · Score: 1

      This means that adding 2G of page space may not cost anything, but adding 2.5G may suddenly take up another chunk of real, non-pageable memory because the page table cannot itself be paged.

      That's not true. For one thing, in most architectures, the page table size depends on the virtual address space size, which is fixed (e.g. 4GB for 32-bit systems). The page table is also usually heirarchical, which means that only the 4KB top level of the hierarchy needs to remain resident; the rest of the page table can be swapped. Even so, a full page table for a 32-bit address space is usually about 4MB per process (with standard 4KB pages), so when we're talking GBs of RAM, it's negligible.

    2. Re:Read (please!) by Anonymous Coward · · Score: 0

      Uh, no. Some 32-bit systems can access more than 4G of memory. With Linux, for example, a large system at close to the full memory capacity (16-64GB) can effectively use up half the low memory. Ingo's patches may help with this, but doesn't change the fact that the memory hit is significant.

  82. 4ms latency swap by Anonymous Coward · · Score: 0

    what if you have a cheap mega commodity drive and the old school small 15k 8M cache u160 scsi diak laying around *cough*

  83. Windows VM performance boost by cciRRus · · Score: 1

    Remember to fix your pagefile / swapfile size, i.e. set the minimum pagefile size = maximum pagefile size.

    Yes, having a pagefile that resizes automatically is more space-efficient, but this will slow down your system whenever you need more memory. I get really irritated when my pagefile increases in size by hundreds of megabytes whenever I load memory intensive games and when my pagefile shrinks back to normal when the games quit.

    --
    w00t
  84. First, understanding virtual memory by jd · · Score: 2, Informative
    In order to determine the correct amount of virtual memory, you need to decide what contingencies virtual memory is being used for. Don't worry with what you are normally doing, because you can always buy enough RAM to do whatever you do normally, on modern systems. On old systems, where physical RAM was capped at a very small amount, you didn't have that option. So, virtual memory today is what you need when there are abnormal conditions.

    The 2.5x case comes from two simple rules of thumb. Firstly, you need enough to be able to hold the whole of what is in RAM now, plus everything you want to swap in, plus enough to minimise fragmentation and cover overheads. Secondly, the more swap space you have, the more metadata you need to manage it AND the greater the latency to perform any kind of swap AND the more swapping you need to do to run all active processes. Too much virtual memory is a Bad Thing. Having 2.5 x RAM was considered a good compromise and it is one I use to this day.

    Today, both rules of thumb still hold. The largest single object you can have is one that fills ALL of RAM after the kernel, and you absolutely must have sufficient swap space to be able to dump that object to disk. If you don't, then the kernel will either panic, kill the process or cause any other activity to behave unpredictably. It won't have the resources to behave correctly. Any number of these objects could, in theory, be swapped out - but remember that they don't run when on disk, only when in memory, so the more you have, the smaller the timeslice each will get - and the sum of those timeslices will go down, as you need to allow time for the swap to take place.

    However, today isn't quite the same as yesterday. The difference in performance between hard drives and RAM has changed. There is better caching on the drive. The swap algorithms are smarter and there is more understanding of what metadata is useful and what really has no value. Process handling is also smarter, so processes aren't necessarily run in order - round-robin scheduling is used for some time-critical stuff on Linux, but most applications use a more relaxed system.

    Also, programming has changed. There is greater re-use of tools and libraries - well, sometimes - and this means that the largest object you really have to handle at a time is much smaller than the size of RAM. A certain fraction of what's left will be used by shared libraries and shared resources.

    Lastly, because hard drives are reasonably cheap and most PCs can handle several at the same time, you are far far better off getting a drive and dedicating it to swap. This is good for many reasons, not least because the drive won't have to move the read heads from data space to swap space and back. You eliminate a vast chunk of seek time, reduce the stress on the drive AND can experiment with different swap sizes without risking losing data.

    I would therefore STRONGLY advise using the classic 2.5x and a different hard drive, but if you can't do this for some reason and want an updated formula, here is what I would suggest:

    The meaningful RAM will be equal to the total RAM minus the space used by the kernel and vital, non-swappable resources/daemons. Multiply this by three for 7200RPM hard drives or by five for 15000RPM hard drives. Multiply by one and a quarter for basic swap schemes, or by one and an eighth for profiling/intelligent swap schemes. Add the size of the hard disk cache, if the cache uses a high water mark to control operations. Subtract the size of the hard drive cache (unless this takes the size below zero) if the behavior is controlled by a low water mark only. Add one megabyte per simultaneous user. Add one megabyte for each large -or- long-running application likely to be running simultaneously. Subtract the total size of all the shared libraries likely to be loaded in the case just considered.

    This is a LOT more complex than 2.5x, so much so that I generally wouldn't bother using it except

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    1. Re:First, understanding virtual memory by Shadyman · · Score: 1

      "If you don't, then the kernel will either panic, kill the process or cause any other activity to behave unpredictably."

      So THAT's what you call it when Windows boots up.

  85. 1x?, 1.5x?, 2x? Jeez Louise by Anonymous Coward · · Score: 1, Funny

    Can't you linucks people get on the same page about this?

    You're 10 years on now, for God's sake; get it done.

  86. VM blah blah by s800 · · Score: 0

    I'm still on AmigaOS.

    1. Re:VM blah blah by Anonymous Coward · · Score: 0

      So how much virtual memory can you actually get on a 3.5" floppy?

  87. Re:heavy windows usage = 0, anything else = defaul by Fry-kun · · Score: 1

    touche :)

    however, may I remind you that
    clarity ~= conciseness/(precision)^2

    I would've used "simulating RAM using HD space" if I had hit the Preview button first ;)

    --
    Did you know that "FTW" ("for the win") is a direct translation of "Sieg Heil"?
  88. Not enough swap encourages *bad* programming by Anonymous Coward · · Score: 0

    The answer, as others point out, is "it depends". Several applications are likely to want to create in-memory data structures of size proportional to their input. Inputs can be huge these days. So you feed an application a large input, it will need Gigabytes of memory.

    But here is the meta-question: is it better for applications to use in-memory data structures or should they do their own RAM management and write stuff to disk? I claim that apps *should* create in-memory structures as much as possible. Virtual memory was a huge advance in programmability. It relieved programmers from managing RAM explicitly. Compare an old-style app (e.g., tex, or an old compiler with lots of stages and intermediate files) to pretty much anything modern. TeX will write lots of intermediate files. This is completely unnecessary and a bad programming style. So, my advice is to give your system plenty of swap. It frees programmers from having to worry about RAM/disk constraints.

    Note that I'm not claiming that all applications should delegate all their RAM management to the OS. There will always be sophisticated apps that will need to manage RAM explicitly. But a well-designed app should only need to do this when the OS's replacement or prefetching policy is not ideal for its usage patterns, *not* just because there is not enough space in the swap file. The latter is a pretty weak reason for doing explicit RAM management.

  89. How's this by 5pp000 · · Score: 1
    I have a quad Opteron with 16GB of DRAM and 145GB of swap (on 15krpm SCSI drives). Do I win?

    (It's for a data mining project. No, I haven't filled all the swap yet, but I'm still coding...)

    --
    Your god may be dead, but mine aren't!
  90. Not sure about that. by barutanseijin · · Score: 1

    It's hard to know what exactly what people are doing with their linux laptops, but since you can choose to suspend to a swap partition from the kernel config, I'd guess that's a fairly popular option. On old thinkpads, I remember having to creat a hibernation file on a dos partition under dos and I'd suspend to that. That's just my experience with my machines ( = apples and thinkpads) & my favourite distros (slackware/slackintosh), but I'd still hesitate to say that the typical linux laptop user suspends to a file in /tmp. What does Ubuntu do?

  91. Depends - not just for the elderly! by Roadkills-R-Us · · Score: 1

    Yes, it depends.

    With Linux, at least, it's completely up to you and what you'll be doing.

    I know of people happily using a 256MB swap space with 1GB or 2GB RAM.

    On a basic system used for firewalling, I have no swap at all.

    At work, we try to have 8GB, even on 1GB systems, because we do occasionally have batch jobs consume tons of memory, or giant databases loading into CAD apps, where drastic slowdownns are still better than lockups or crashes. But a screwup in making install disks resulted in a bunch of desktops with 1GB swap and 1GB or 2GB RAM, and only a couple of them have problems. Our proxy server and mail gateway have a small swap space as an emergency precaution since we never, ever want them to die. Slow is better than dead, and the monitoring software will catch the slowdown.

    My file server at home has a swap the size of RAM, just to be safe. The "workstations" have swap spaces at least 2X RAM, just to be safe. Once in a while, doing something hairy in GIMP on a large image, this has saved one of our fannies.

    1. Re:Depends - not just for the elderly! by Anonymous Coward · · Score: 0

      haha... you said hairy and fannies in the same sentence... (fanny from a British perspective, btw)

  92. Too much is counterproductive by sam991 · · Score: 1

    I'm just a lowly A+ in training, but it seems to me that anything more than 1.5x your physical RAM is counterproductive as it means a lot more read/write cycles over the course of any given period. 1.5x is what everyone i know uses and i've never known any more to impact performance in a beneficial way.

    --
    "No, no, no, don't tug on that! You never know what it might be attached to."
    1. Re:Too much is counterproductive by Miniluv · · Score: 1

      You have a flawed assumption that allocating swap will make it be used. Further, read/write cycles are "free" on hard disks, as they don't really have a finite number in them. If you were using NAND that'd be different.

      1.5x is one of those "rule of thumb" values that some folks subscribe to. Others go with 2x, others with 1x. None of them are hard and fast, each is based on certain operating environments and requirements.

      I run a number of production systems with no swap at all, some with 1x, some with larger (Oracle requires ridiculous amounts of swap for some unholy reason).

  93. No...not really by Chas · · Score: 5, Informative

    There's no real hard and fast rule anymore. And setting it against a static value (like physical memory) is incredibly wasteful.

    It's a much better idea to set it interactively. Use the system without adjusting the Virtual Memory for a while. Then take a look at your usage and set your virtual memory against that usage.

    For instance.

    If you're in a Windows machine, let it run normally for a few days.
    Run everything the way you normally use it.
    Multiple apps, multiple instances, games out the ass, everything.

    Then open up the Task Manager and look at the Performance tab.
    Take a look at the Peak value under "Commit Charge".
    Set your virtual memory, min and max, at about 10% above that value to leave yourself a little headroom.
    Normally this will be enough to deal with your maximum swap requests.

    If, somehow, you begin bumping against virtual memory limits again AFTER that, bump it another 10%.

    If you still have problems, keep bumping it in 10% increments, and start looking for apps that are memory leaking.

    --


    Chas - The one, the only.
    THANK GOD!!!
  94. With the current prices by houghi · · Score: 1

    Who cares with the current prices. Just take the old standard. Twice as much as your 'nirmal' memory. So what if that means you take up 4 GB of your 2GB machine and you never use 3.5GB.
    Your freaking HD is probably 200GB
    Use your old 8GB HD if you like, it doesn't do anything else.

    On Linux it is like this; if you need your swap a lot, add memory. If you use your swap a lot, it might be more importand WHERE you place your swap. Devide it over different HDs. Put it on an HD that you seldom use. That kind of stuff.

    --
    Don't fight for your country, if your country does not fight for you.
  95. Re:heavy windows usage = 0, anything else = defaul by spuzzzzzzz · · Score: 3, Informative
    ...unlike Linux, which uses it only when there's no other way (reactive)
    Not quite true. Read this.
    --

    Don't you hate meta-sigs?
  96. I've needed 2 Gig for Windows before by lilmouse · · Score: 0

    I've needed > 2 Gig on a Windows system before. And this is with 2 Gig of RAM. Yes, that's right, I've needed this. Granted, I was running multiple instances of a memory intensive application (finance), which is not what a "normal" user would see... But, you can't just say "Oh, no one needs a pagefile" without some pretty hefty fine print. Anyway, after Windows made a total mess of instantaneous resizing, I changed all the machines to use 2 Gig pagefiles.

    Linux? Dunno, I'm gonna go for the 1.5x RAM :-) (thanks ppl!)

    --LWM

  97. But really, who cares? by mcrbids · · Score: 4, Insightful

    My strategy generally is to use a file for swap rather than a partition, even in linux.

    What I find curious is that you have a strategy. On what relevant experience do you base this strategy? 1 GB of disk space costs less than $0.50. Set up 3 GB of VM if it makes you feel good. The latte you drink while you set it up costs more than the extra disk space!

    So go for it!!! Who cares what you do? Heck, give yourself 10x the RAM and see if it actually makes any difference!!! (it won't)

    This is sort of like asking: "Which goes faster: the yellow Pacer or the red Pacer?"!

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
    1. Re:But really, who cares? by Jeremi · · Score: 0
      Set up 3 GB of VM if it makes you feel good.


      Isn't having too much swap potentially harmful, though? If you have little or no swap configured, and a buggy process starts endlessly allocating/leaking more and more memory, then memory will fill up, the swap space (if any) will quickly become exhausted, the buggy process will be terminated, and the rest of the system will continue on its merry way. If you have large amounts of swap space, on the other hand, your system may spend hours or days in a sort of 'near-death experience', where all processes are technically still running, they are all constantly being paged on and off the disk, resulting in a computer that is running too slow to be usable. During that period, the computer is just as useless as if there had been a complete BSOD system crash.


      But maybe I'm missing something... is there a technique that OS designers use to avoid this problem?

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    2. Re:But really, who cares? by mcrbids · · Score: 1


      Isn't having too much swap potentially harmful, though?


      Sure - in much the same way that having a red Pacer is harmful.

      Yes, something could go wrong. Your dog could go rabid, bite you, and you could die. That's probably many times more likely than the scenario you paint. In short, if you like red Pacers, go for it - it sure won't hurt you any more than any other Pacer.

      The only people who should care about how much VM to allocate already know how to allocate it. This is something that should be automated by your distro installer, and should be something that you aren't informed of anymore than the value of SHMMAX.

      Yes, there are times where SHMMAX matters. And if you are asking about it, you should already know how to get the right answer, otherwise you are just seriously out of your league.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    3. Re:But really, who cares? by Jeremi · · Score: 1
      That's probably many times more likely than the scenario you paint.


      I don't know about that... it's probably happened a dozen times over the last few years that a bug in the program I was developing would cause the program to allocate memory in an infinite loop. When that happened, it was usually a big PITA to recover, because the GUI would become so unresponsive that it was very difficult or impossible to issue the command to kill the runaway process. On the other hand, I have yet to be bit by any rabid dogs... :^)


      The only people who should care about how much VM to allocate already know how to allocate it. This is something that should be automated by your distro installer,


      Sure, I'll agree with that... but out of curiosity, how do the distro developers decide what the "best" value should be? It seems to me that the best setting would always be to disable the swap file entirely, and just buy another $30 gigabyte of RAM if you find yourself running out...

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    4. Re:But really, who cares? by Nefarious+Wheel · · Score: 2, Interesting
      So go for it!!! Who cares what you do? Heck, give yourself 10x the RAM and see if it actually makes any difference!!! (it won't)

      In general, I approve of your philosophy. But remember there are addressing overheads to map all that disk space into memory, and all that page management can give you a bit of a performance hit too. It isn't the cost of disk, it's the cost of managing it that means you have to put a little bit of thought into it. I know the stuff is cheap, but you still have to compute with it.

      Or to quote my favorite philosopher, Yogi Berra, "In theory, there's no difference between theory and practice. In practice, there is".

      --
      Do not mock my vision of impractical footwear
    5. Re:But really, who cares? by Angostura · · Score: 4, Funny

      Are you aware of the ironic disconnect between the content of your posting (If you need to ask, you don't need to know) and the content of your .sig?

    6. Re:But really, who cares? by ultranova · · Score: 1

      If you have little or no swap configured, and a buggy process starts endlessly allocating/leaking more and more memory, then memory will fill up, the swap space (if any) will quickly become exhausted, the buggy process will be terminated, and the rest of the system will continue on its merry way. If you have large amounts of swap space, on the other hand, your system may spend hours or days in a sort of 'near-death experience', where all processes are technically still running, they are all constantly being paged on and off the disk, resulting in a computer that is running too slow to be usable. During that period, the computer is just as useless as if there had been a complete BSOD system crash.

      But if the process leaks memory, then the leaked memory is not accessed afterwards (by definition of being leaked), so the system would soon start swapping it out, instead of swapping out actual constantly accessed memory of other running proceses. In other words, the new allocations push old ones to swap.

      Or you could set limitations to process memory usage. That should stop the process right on its tracks.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    7. Re:But really, who cares? by Anonymous Coward · · Score: 0

      which is faster the yellow or red pacer???

      Well the funny thing about this is that colour does matter to a cars speed. Different colours are made of different pigments, certain colours can weigh MUCH more per gallon then other colours.

      So if you are the type of person who rips out their speaker wires to save on weight to get that little bit more, well then yellow or red matters......

    8. Re:But really, who cares? by The+Munger · · Score: 1

      The red Pacer ;-)

      --
      Refuse to make a statement in your sig!
    9. Re:But really, who cares? by Anonymous Coward · · Score: 0
      I don't know about that... it's probably happened a dozen times over the last few years that a bug in the program I was developing would cause the program to allocate memory in an infinite loop.

      Doctor it hurts when I do that...
    10. Re:But really, who cares? by ATMD · · Score: 1

      A $30 gigabyte of RAM will cause lots of crashing. Don't buy it.

      (Says the guy with the $150(ish) gigabyte of ram :)

      --
      Nobody else has this sig.
    11. Re:But really, who cares? by Panaflex · · Score: 1

      Yep.. as a developer you are RIGHT.

      But for a USER, who just needs a couple of megs more to get his little drawing printed or whatever.. swap makes perfect sense. Ideally, it wouldn't be used much - and if it is - it's a signal to the user that says YOU NEED MORE RAM DUMMY!!! This is better than "This process has been killed unexpectedly" type messages you used to see - or the ever better complete system lock as the mouse subsystem tries to allocate a position structure to send as a message to the application - and fails.

      I actually only use my swap for one thing on my laptop now - hibernating. And it works, works fast, and well and I'm durn happy with it.

      Swap on! heheheh

      --
      I said no... but I missed and it came out yes.
    12. Re:But really, who cares? by Jeremi · · Score: 1
      swap makes perfect sense. Ideally, it wouldn't be used much - and if it is - it's a signal to the user that says YOU NEED MORE RAM DUMMY!!!


      Well, you have to admit it's not a very obvious signal... most users aren't well-enough informed to necessarily know what is causing their computer to run slowly; they'll probably think they've caught a virus or something. A better notification would be an actually dialog box opening saying something like "Out of memory... YOU NEED MORE RAM DUMMY!!!", so the user knows exactly what is going wrong.


      This is better than "This process has been killed unexpectedly" type messages you used to see - or the ever better complete system lock as the mouse subsystem tries to allocate a position structure to send as a message to the application - and fails.


      Those things are just symptoms of an operating system that doesn't handle out-of-memory situations properly. A proper operating system would be designed to handle our-of-memory situations without locking up or causing "mysterious" failures. (it might well have to kill some processes, but if it did it would inform the user as to why it did so). Yeah, I know handling out-of-memory is a hard problem, and that the last OS that actually attempted it was probably AmigaDOS... but that doesn't mean it shouldn't be handled. That's the other problem with swap space, it gives developers an excuse to pretend that they don't have to worry about handling memory exhaustion :^)

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    13. Re:But really, who cares? by wyohman · · Score: 1

      This is sort of like asking: "Which goes faster: the yellow Pacer or the red Pacer?"!

      Nope. Everyone knows RED is always faster. Pacer or not!

      Cheers.

    14. Re:But really, who cares? by orev · · Score: 1

      As long as everyone does the same thing you do, there's no problem, right? The problem is that on a server, disk space is still very expensive. a 36 gig scsi drive is still a lot, and 1 or 2 extra G for swap is a pretty big chunk.

  98. Dang.. it wasn't that long ago when.. by zoid.com · · Score: 1

    I was setting up SLS on a 4meg 486SX with coprocessor emulation and dreading the fact that I had to give up 8meg of disk space for swap. 2 gig swap... bah...

  99. depends on the role, but.... by CAIMLAS · · Score: 1

    It all depends on the system's role. Common desktop, lotsa RAM? No swap. Medium RAM, common desktop? No RAM. Anything with more stringent requirements or less RAM, add swap accordingly...

    But then again, when a 250G disk is like $80, what's another 3 or 4G of used space?

    --
    ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
  100. It depends on management and applications by bjverzal · · Score: 1

    Swap space in my experience depends on management and the application. I had a manager previously that came from a mainframe background and had a specific amount he wanted (2.5x RAM). I showed him documentation time after time showing swap space under utilized, but any time there was an issue, he brought up the swap space. Also, SAP will complain if there is not a very specific amount of swap space.

  101. Please memorize this equation by slavelayer · · Score: 3, Funny

    Before talking about swapping, pagging, and virtual memory please learn and understand this equation: Virtual Memory = Physical Memory + Swap(or Page) file. I let the OS (windows) manage my page file. The current generation of windows OS's (2k, xp, & 03) mange the swap file much more efficently than windows 9x did. All this mumbo-jumbo about tweaking the swapfile came about because these old versions of windows needed to be tweaked, they had memory problems and tweaking the swapfile would improve performance and stability. But the current generation of windows has no need for tweaking the swapfile, save for some special server situations. Its a waste of time to personally manage the swapfile for a desktop/development computer.

  102. min(2*RAM, 512Mb) by YGingras · · Score: 3, Interesting

    I never user more than 512Mb of swap. If you have a runaway process, you can let it live but you avoid a lot of trashing. If more than one process start consuming RAM like crazy you, actually want them to die from an out-of-mem error otherwise your whole system will grind to a halt while it spends most of its time unswaping one and the other. At 512Mb you can do a little excess of memory usage but won't go beyond what you can unswap in a time quantum (mostly).

    Smarter per-process ressource quotas would probably be better and it would be nice to have a trashiness function according to the disk speed but so far 512Mb sounds like the limit between using the resset button or just taking a coffee break when you see the HD led blinking like a strobe.

    It is just easier to try the approach where you consume a lot of RAM first and to re-code if it doesn't work. I work in bioinformatics and we often have huge datasets, I alway try to load the whole thing and to make the computation in RAM. Only when I get and out-of-mem error do I segment the dataset and try a smarter approach. That might explain my choice for 512Mb and the right threshold for other people might be bigger or lower but I'm pretty sure that its bellow 8Gb.

    1. Re:min(2*RAM, 512Mb) by MrNemesis · · Score: 1

      I'm in total agreement with you on this. My desktop has 256MB swap and 1GB of RAM. The only time Linux has ever touched swap was when I was importing 8GB of Eudora psuedo-MBOX files into KMail (I forget the exact command I was using). At the time I had 2GB of swap (rule of thumb, right?), and the import process swallowed it all up. I didn't notice in time and the system became completely unresponsive; not even a Ctrl-Alt-Backspace worked. I couldn't ssh into the machine either. Eventually the process died, but it took a good 30 minutes.

      My MythTV backend with 2GB of RAM touches maybe 5-10MB of it's 2GB swap at the worst of times, even with quite a few memory hungry apps (Opera, amarok, myth transcodes) running as long as the system is up and pre-emptive swapping turned on.

      When a process goes nuts, I want it to be killed ASAP. Leaving it to fill up xGB of swap and bring the server to its knees for x minutes is silly. I admit that in machines with less RAM than mine swap is a great idea, but on modern machines the overhead for using virtual RAM seems much higher, and I get no obvious performance increase from it, even with 10k RPM drives. Since the 4GB barrier isn't a problem any more for server at work (64bit Debian, yay!), we just plumped for gobs of RAM instead of new servers every x years (since we don't do much that's CPU limited). Heck, I even have MySQL DB's mounted in tmpfs at home. I don't mean to sound harch, but swap just seems to be a way for those unable to stuff more RAM into their boxes to stretch their budgets a little further...

      --
      Moderation Total: -1 Troll, +3 Goat
  103. swap-ing is sad by Anonymous Coward · · Score: 0

    i'd really like to not have to swap at all.
    it would be neat if the OS just said, sorry boss
    no memory left close something else first.
    on XP it seems impossible to disabel the pagefile/swap
    and even if disabling tons of services etc. running
    notepad it will still swap.

    anyway, since we can't get around it, live with it
    the samrt way. if you install XP or linux or ...
    remeber to make the very first partition your swap. the
    idea is that the first partition is nearer to the center
    of a platter, e.g. the seek and write times will be faster
    then at the edge of a hdd platter.
    my first partition C: is called PAGEFILE and is 3GB big and
    i have 764 MB ram. the only thing on it is the pagefile for
    XP.
    same for linux first partition is swap.
    last thought swap is not "BAD", but the way a OS decides to use
    it can be bad.

  104. my thoughts by Anonymous Coward · · Score: 0

    Swap is useless unless you use firefox. The concept of swap is a big BS. If you dont have enough ram , it's better the program will be closed than wait till it hits the swap and dies anyway.
    The need to close the program will remind you that your resources are indeed limited and will not permit alot of vendors to bundle crap with new pc since it will eat all the ram away.
    I dont really see any benefit of swap. Why not make programs just resume upon reopening. Why not spen some time writing quality software. The absence of swap will make gnome/kde guys consider how to program efficently, it will make people think if the schould use maybe utorrent instead of azureus with the effect of being able to edit something in photoshop. And as a result the people developting Azureus/firefox will actually fix their bugs or noone will use their software.

  105. Is swapping obsolete? (was:Rules of thumb are dumb by Jeremi · · Score: 4, Interesting
    To this day, i never put more than 256m as swap even on servers with 4G of ram. that's where we had the least problems.


    That raises the question: is swapping obsolete? Or to put it more explicitly, has the speed difference between modern CPUs and hard drives become so large, and RAM so cheap, that it's better to consider running out of RAM to be indicative of a software failure? That way you end up with a system where one or more processes may fail (or be terminated) but at least the machine remains usable and doesn't swap itself into non-responsiveness.


    In my experience, the answer is yes: with 2GB of RAM in my machine, I never need to swap, and in the few instances where swapping did occur, it was because of buggy software (memory leaks) and manually terminating the offending processes is what I needed to do resolve the memory shortage. So why not just have the OS do that automatically?


    Or to put it a third way, is there any situation where swapping is helpful, anymore?

    --


    I don't care if it's 90,000 hectares. That lake was not my doing.
  106. godaddy and virtual dedicated by kcornwell · · Score: 1
  107. OS/2 swap files by Anonymous Coward · · Score: 0

    Change the line in CONFIG.SYS: SWAPPATH=:\ is how much free space is left before the OS alerts you to running out of swap space. is the initial swapsize Example: SWAPPATH=C:\OS2\SWAPPER.DAT 4096 12880 4MB minfree, 12MB initial swapsize. You can even swap to a RAM disk, see this page To turn off swapping, in CONFIG.SYS, use the line MEMMAN=NOSWAP,PROTECT

  108. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  109. Uh, no. by jd · · Score: 1

    For Windows, omit the word "either" and replace "or" with "and".

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  110. Well... by eliot1785 · · Score: 2, Funny

    ...I see your swap is as big as mine...

  111. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  112. Thrashing to Death with Plenty of Memory Available by javaxjb · · Score: 1

    Thrashing is even worse when the system doesn't allocate enough ahead of time. One of my Java programs (unintentionally) brought down a production AS/400 in the middle of the work day. A third party utility for running batch applications allocated the Java program to a 1 MB (max), single threaded pool. This was a program that used three threads of its own (plus however many the JDBC process spawned, which was probably at least two). So somewhere between swapping all of those thread contexts into a single threaded workspace and managing at least 64MB (and probably closer to 128MB) in a 1MB window, you might say that it converted OS/400 to DOS. The amazing thing is that it had run successfully several times prior (we were trying to figure out why it was running so many orders of magnitude slower when running in batch vs interactive).

    --
    Programmers in mirror are brighter than they appear
  113. Listen to Mr Cray. by haeger · · Score: 5, Funny

    "Memory is like an orgasm. It's a lot better if you don't have to fake it."
                      -- Seymour Cray, on virtual memory.

    --
    You are not entitled to your opinion. You are entitled to your informed opinion. -- Harlan Ellison
    1. Re:Listen to Mr Cray. by Anonymous Coward · · Score: 0

      Amen

    2. Re:Listen to Mr Cray. by Gnavpot · · Score: 2, Funny
      "Memory is like an orgasm. It's a lot better if you don't have to fake it."
                                          -- Seymour Cray, on virtual memory.

      It is usually recommended to use analogies which the target audience can relate to.
  114. 800Mb - On a 3GB ram system by grainfed · · Score: 1

    Windows just wouldn't stop swapping out shit that I had been using two minutes ago - so I gave it bugger all to run with. I figure 3.8GB of address space is enogh for now. Screw giving it more. I would turn it off, but PS bitches about lack of a swap file.

    --
    ~/words_by_grainfed.txt
  115. Re:Is swapping obsolete? (was:Rules of thumb are d by ookaze · · Score: 2, Informative

    Yes, swap is useful in any situation when you don't know if you'll have enough RAM to run everything.
    And RAM can be so "cheap" as you say, but disk is still far cheaper.

    With swap, you also have some way to find out that you're running out of memory. You can monitor it, and you can also sometimes see a performance decrease (if it's a desktop), though you'll probably not notice it with SCSI disks. But you still have the monitor, right ?

  116. Paging VS Swapping by candude43 · · Score: 1

    Use of terminology has varied between system architectures and over time, but on the big systems I grew up on, paging referred to the process of writing out 4K chunks (pages) on a LRU basis. Swapping was the process of writing out an entire application or address space. The purpose of paging was to share memory resources, wheras swapping was mostly intended to reduce the number of applications actively competing for CPU resources.

  117. Re:Is swapping obsolete? (was:Rules of thumb are d by Anonymous Coward · · Score: 0

    Or to put it a third way, is there any situation where swapping is helpful, anymore?

    More filesystem cache is almost always useful, and swapping out unused pages will allow you to have a larger filesystem cache.

  118. Re:Is swapping obsolete? by shani · · Score: 3, Informative

    Or to put it a third way, is there any situation where swapping is helpful, anymore?

    Sure. Consider Andrew Morton's logic:

    http://kerneltrap.org/node/3000

    In your average program, most code never gets executed, and most data is never used. For a long-lived process, swapping out the unnecessary bits frees the memory for disk cache.

    While you may improve overall performance, by minimizing the average completion time for operations, the downside is responsiveness. As a user, I don't care if Firefox reads cached images a few milliseconds faster (by reading from cache instead of disk) if I have to wait 3 seconds for Thunderbird to respond to my clicks (because it has to swap in) after I've been browsing for a while. Average speed be damned! :)

    Having said that, I just set my swappiness to 100.

  119. Re:heavy windows usage = 0, anything else = defaul by julietmikealpha · · Score: 1

    There's a single issue I take up with the above post. Just loading a bunch of applications won't give a good indication of memory usage. Load of some work with them, projects or code. Open a few web pages, etc... Those apps will start to grab more memory leading to a more accurate indication of memory use. Devstudio, for example, just shot up from 60MB to 260MB just opening a project. Never mind actually trying to build something :)

  120. The amount of virtual memory is fixed by hkultala · · Score: 1

    It's always 2^virtual memory address bits of the processor.

    Sometimes the amount of virtual memory available to programs is smaller due the operating systems reserving some part ( like upper half ) of the virtual for itself, so on most operating systems on the most common settings on the most common hardware there is always 2 gibibytes of virtual memory for every process.

    Swap file and virtual memory are differnt things. If you are talking about swap file, use the term swap file.

  121. "It Depends" by edward.virtually@pob · · Score: 2, Insightful

    The equation stays about the same though the scale of memory sizes involved increases. If one ran a set number of processes that all fit within core (RAM) memory and did not increase in size over time, one wouldn't need virtual memory at all. When using a properly sized computer of a given generation, the typical set of processes being run fits in or almost fits in core memory, so a virtual memory size equal to the core size provides ample protection against memory exhaustion (both core and virtual memories full). Exactly how much memory this is increases as the sizes of those typical processes increase. These days 2gb of core is usually large enough to avoid the need to use virtual memory, but it can be consumed pretty quickly by either large numbers of typical processes or a few memory intensive ones. Memory exhaustion is a very unpleasant situation and leads to data loss and service outages. The computer does not react well to having literally no room to think. So given this, and that virtual memory (disk space) gets cheaper at (somewhat) the same pace as core (RAM), it is much safer and cost effective to err on the side of caution and make the virtual memory bigger than necessary for day to day operation. Regardless of the scale of the current generation memory sizes, a virtual memory space equal to one or so times the core space of a properly equiped machine is the right size. For small core machines, the larger the core memory deficit, the more times larger the virtual memory space must be to avoid running out of total memory. A machine running the latest Windows environment in 512mb of core would need a virtual memory much larger than one or two times that size to be safe. Said machine would still perform very poorly due to the cost of continually accessing the virtual memory, but it would avoid crashing due to memory shortage. Systems with much more than average core memory may be able to do safely with less or even no virtual space, but it is arguably a foolish place to conserve since disk space is cheap and maintaining at least a one times core sized virtual memory space is insurance against the pain of memory exhaustion.

    Or distilled: less RAM than average needs more than two times that for virtual, average RAM needs one to two times that, and lots more RAM than average can probably get away with less than one times or even none but probably should use one times anyway.

    Again note that average refers to the RAM size of a current generation machine configured to run the typical number of typical current programs with reasonable performance.

  122. (my) Current rule for Linux by pieleric · · Score: 1

    I take care of few machines (for my surroundings), all under Linux, and with the current state of the art of the kernel my rule of thumb is that: swap = 2*RAM if swap > 1Gb swap = RAM I always put at least as much RAM as swap in order to allow for suspend to disk.

  123. Personal experience by Drysh · · Score: 1

    When using tmpfs create a huge swap. For normal use you won't need it, but when you decide to compile some packages it will use it all. Around 5GB swap + 2 GB RAM is enough (for me).

    Note that this is a fail-safe measure. It will work with 2 GB RAM + 1 GB swap, but sometimes it breaks... And you don't want to get a disk full error after a few hours compiling something. Another option is to de-activate tmpfs before compiling huge things (but I never remember to do that).

  124. Still true by jandersen · · Score: 1

    But always remember, virtual memory is only there to buy you time, so you can keep running until you can increase main storage.

    And, of course, if at all possible, use several smaller swap partitions on SEPARATE disks to get better performance.

    1. Re:Still true by EmagGeek · · Score: 1

      Or use one partition on a Raid-0 array...

  125. All memory is virtual these days! by Terje+Mathisen · · Score: 3, Insightful

    What the original article didn't mention, and none of the replies seemed to go into, is the fact that with current CPUs, effectively all RAM is 'virtual':

    Only on-chip memory, i.e. cache, is "real" these days, and all accesses to DRAM will be handled in paging units of 64/128 bytes or so. If this sounds familiar, it should! CPUs with 1 to 4 MB of real memory and lots of virtual memory is what the mainframes and minicomputers had about 20-30 years ago.

    What this means is that now, just like then, all performance-critical code needs to be written to keep the working set within the amount of "real" memory you have available. When you passed this limit, you needed to make sure that you handled paging in suitably large blocks, to overcome the initial seek time overhead.

    Today this corresponds to the difference between random access to DRAM and burst-mode (block transfer) which can be nearly an order of magnitude faster.

    In the old days, when you passed the limits of your drum/disk swap device, you had to go to tape, which was a purely sequential device. Today, when you pass the limits of DRAM, you have to go to disk, which also needs to be treated as a bulk transfer/sequential device.

    I.e. all the programming algorithms that was developed to handle resource limitations on old mainframes should now be ressurected!

      "those who forget their history, are condemned to repeat it"

    Terje

    --
    "almost all programming can be viewed as an exercise in caching"
  126. None by jevring · · Score: 1

    I have 2GB of ram now, and I don't use a swapfile on windows. I even play wow with this setup, and blizzard games are notorious for eating up every available resource (diablo2 even created it's own pagefile when it felt like it) swapfiles are the devil. they are a remnant of times when ram was expensive. they are a solution to a problem we don't really have anymore.

    --
    Move sig!
  127. Probably less than 2x physical RAM by Anonymous Coward · · Score: 0

    Hard disks are too slow to provide useful virtual memory of anything close to / above 2Gb. If your machine is swapping over 2Gb to disk, performance is likely to be poor during swapping, as whatever process is trying to allocate memory that is not available will block waiting for I/O while other proceses allocations are swapped out, and whatever is applications pages are swapped out will also block when it tries to access the swapped data again. There is absoletely no point in allocating much more than 2Gb, particularly with the low cost of physical memory. Hard disks are simply not fast enough. Again, it really depends what you are going to do with your computer, but if you have a typical 2-4Gb of RAM in a decent desktop computer, most machines running a few applications are not going to have a problem anyway. With 4Gb+, I'd say you can get away without a swap at all, but it's always nice to have some fallback if you are running some kind of huge job.

  128. Fast swap by Aceticon · · Score: 1

    Dunno about Windows, but in Linux if you want a really fast swap space you make a virtual disk in memory and set it up as your swap space.

  129. There is no such thing as virtual memory by waimate · · Score: 1
    As a very smart man I used to work with used to say, "there is no such thing as virtual memory".


    For a while, I thought he was just having a play on words, but after a while I realised it was actually a very important observation about performance in computing systems, and if you make the mistake of thinking virtual memory was in any way as good as real memory, you were headed for tears. In these days of cheap RAM, if you need 4GB, install 4GB, and be done with this foolishness of thinking hard disk is just as good.

    Of course, in reality it's always good to have a few unused holes on your belt, and VM is a useful thing. Just don't think it's in any way as good as real. For best performance, the optimum ratio is 1:1. That's the message.

  130. ulimit by shish · · Score: 1
    their script was leaking memory. eventually consuming all ram (2.5G) + all swap (1-2g)

    Which is why I set ulimit caps on my server, so that no process can use more than eg 256MB of real memory and 64MB virtual (a soft limit, so it can be raised if necessary). Then I get all the speed benefits of swap space, a short time of degraded performance if the process starts leaking, then it dies of memory loss; all the other processes carry on as normal, since there's plenty of ram free, just no single process can use it all.

    --
    I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    1. Re:ulimit by Feyr · · Score: 1

      the problem wasn't one process consuming it all, the problem was one script being run 200 times, staying in memory (mod_perl script) and leaking over the 200-300 requests it processes over time (limiting each scripts to 100 requests before being killed limited the problem somewhat, but it still happened)

      to be fair, i did try to mess with ulimit, but it's a bit retarded in itself and it didnt work properly

    2. Re:ulimit by Anonymous Coward · · Score: 0

      Then you didn't set those limits right. FreeBSD probably worked ok since it has sane login class limits set by default, same with the other BSD's. Solaris doesn't have them set by default, by lets the good admin set up some wacky limits via projects and kernel settings. Not sure what linux offers, other than shell limits, but in the past those have worked fine for me.

      Also i guess you have never run into the problem of having an OS on which you needed to capture a kernel+system coredump to analyze - you'll need swap >= ram plus a real crash dir to hold the data after reboot.

      But yeah part of admin'ing is making sure no one user/process tree can knock out the system, even apache. On my solaris zones i've been setting up max ram limits for apache, then max total memory. In general our most used apache instances stay under 4GB use, but if they go too high then they start to swap out for up to 2gb more, leaving ram for other processes, like me getting the alert, logging in and determining what the problem is (generally calling the web programmers up and saying "you did it again"). Similar limitations on other process groupings.

      Solaris is a bitch out of the box (hey! let's fill up /tmp in a subzone and mess up everyone else!), but provides some great tools for restricting processes. *BSD is awesome out of the box and provides some decent tools for limiting users. Most mainstream linux distros i've tried are also a bitch out of the box, and provide rudimentary tools for restricting (but has been a few years, perhaps the SElinux or other project stuff has helped?).

      A nice thing to try on your new system is: create generic user, login as generic user and other user, run forkbomb as generic user, see if other user account is still useable. Now set good limits until such threats are minimized. Do same for processes using all ram, all swap, disk IO (anyone but AIX handle that?), etc etc. Welcome to sysadmin. I go home now.

    3. Re:ulimit by Feyr · · Score: 1

      you do realize that ulimit (at least in linux) is per session right? protecting against one fork bomb is easy, protecting against one user running a forkbomb in X different terminals (where X is the number required to exceed the limit) is an entirely different job

      and what do you set the limit at when the server's sole job is running apache? same as the server's memory? turning off (or seriously reducing) the swap does roughly the same thing and it protects you from all the potential (ab)users.

      if i've missed something, feel free to correct me.

  131. OSX - 4 gigs RAM, 14 gigs swap?!? by cruci · · Score: 1

    Unless I'm reading the activity monitor wrong, I have 4 gigs of physical RAM, and 14 gigs of virtual RAM at the moment. This is a dual 2ghz G5, running 10.4.7.

    I currently have Photoshop, Firefox, Azureus, Skype, Adium, Entourage, Mail, and Safari running.

    The thing is, I am constantly running out of memory, or rather, constantly getting down to 40megs free. Trying to do anything in Photoshop at that time is incredibly slow, which is crazy because PS has it's own swap files/scratch discs...

    1. Re:OSX - 4 gigs RAM, 14 gigs swap?!? by Anonymous Coward · · Score: 0

      Well the free memory SHOULD be getting down pretty low, that means that OS X is utilizing as much memory as possible. As for it slowing down, maybe one of the programs you listed has a memory leak, you should try isolating the program or looking at the logs (I know Azureus' log shows mem usage in ~/Library/Application\ Support/Azureus/logs/thread_?.log). Also that 14 gigs of virtual RAM is pretty normal, it probably is only taking up ~4 gigs on your actual hard drive.

    2. Re:OSX - 4 gigs RAM, 14 gigs swap?!? by ajcarr · · Score: 4, Informative

      The VM Size listed in Activity Monitor is not the size of the swapfiles. I'm running on a machine with 1 GB RAM, my VM size is 6.53 GB, but I only have 128 MB of swapfiles. You might find it interesting to intall MenuMeters http://www.ragingmenace.com/software/menumeters/ to keep track of what's going on.

  132. Swap is not just a slow ram extension by shish · · Score: 1

    Currently you have say 512mb of process memory, and 512mb of in-memory cached files (the kernel keeps commonly accessed files in ram to speed reads); with swap, you could move 256mb of idle processes to swap (you won't notice the processes slowing down, since the're idle anyway), and have 768mb free for caching files.

    The only time people notice swap slowing things down is when they don't have enough ram to keep active processes in main memory, and the couple of seconds lag when eg you've had firefox minimised for a day (so the OS thinks the process is idle, and swapped it out), and it takes a while for the hundreds of megs of process to get back to main ram.

    --
    I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
  133. The rule of thumb still applies by Damouze · · Score: 2, Informative

    In my opinion the rule of thumb still applies. No matter what you are going to do with your system, it never hurts to have (more than) enough swap space. Like several people mentioned earlier: the more free RAM you have, the more RAM is available to the OS for the disk and buffer caches.

    There is, however, a potentially severe case if you have two processes accessing the same resource simultanously. Every good informatician and computer programmer knows that such a case is the ultimate no-no in software engineering. Unfortunately, there are scenarios thinkable, in which it will happen nonetheless.

    Back when I was still working on my Bachelor's degree I and a couple of friends of mine tried to simulate this theoretical possibility and see what happens. We had two processes, called 'ss1' and 'ss2', accessing the same resource at the same time:

    ss1 would create a file sized X and go into an endless loop writing random bytes at random positions in the file. ss2 would open that file and mmap() it. That way it would be in the buffer cache as long as data was written to it (and since data was written to it by the other process, that was actually the case). The result of the mmap() was a character array and ss2 would write random bytes to that character array at random positions.

    We tested this on the following OSes: Linux 2.0, Linux 2.2, Solaris x86 (can't remember which version), FreeBSD 3.3, Irix 4.0.5, 5.3 and 6.2 and Windows NT 4.0 Workstation. We ran the application with administrative or superuser privileges.

    As long as the size (X) did not approach half the physical amount of RAM present in the machine, there were no problems whatsoever. However, as soon as X passed that threshold, bad things started to happen. The only exception was Windows NT, which simply aborted the process with a page fault and an out-of-memory error.

    All the aforementioned machines that were running Linux or a variant of UNIX, suffered the same problem: a non-responsive system. The processes could only be terminated by doing a hardware reset of the machine. A kill -9 of the two processes did not work, because they were in a non-interruptable sleep. And the reason they were was that the OS was trying to fullfill the resource demands of the processes by swapping out other stuff, including, as we theorized, other parts of the file that were not "hot" at that time.

    This piece of intentionally bad-written software and intentionally bad system operatorship of course proved that, while it was highly unlikely to happen, it could happen and would have dire consequences for the system.

    Ordinarily, one should never run programs as a privileged user unless one absolutely has to and the two competing processes would have been terminated by the OS had they not run as root on the Linux and UNIX machines. But regardless of whether the OS in question uses the optimistic or pessimistic approach when allocating resources for a new process, the net result of having such a (in our case intentionally) badly written piece of software is the same: the system becomes non-responsive.

    In this case, it does not matter much how much swap space you have, the only difference is that if you have only a little amount of swap space the "dreaded" OOM killer starts to kill of processes at a very early hour instead of when it is already too late (and virtually incapable of functioning properly and actually do its job).

    Personally, I would still recommend using at least the same amount of swap space as you have physical RAM, and preferably at twice the amount. Bad things happen all the time, and it is better to be prepared for it. Therefore, the rule of thumb still applies.

    --
    And on the Eighth Day, Man created God.
  134. Yup. On Windows, just use "None." by rjstanford · · Score: 1

    I have 2gb (maybe 2.5gb, I don't remember) in my Windows machine, and I just disabled the swap file. The only times I ever have issues is when I'm working a memory leak, and I'd have issues with that no matter how much swap space I used. RAM is cheap enough to make this a non-issue. Besides, it makes Eclipse feel really snappy not to keep having its plugins swapped out from under it.

    --
    You're special forces then? That's great! I just love your olympics!
  135. Re:Is swapping obsolete? (was:Rules of thumb are d by Kjella · · Score: 1

    In my experience, the answer is yes: with 2GB of RAM in my machine, I never need to swap, and in the few instances where swapping did occur, it was because of buggy software (memory leaks) and manually terminating the offending processes is what I needed to do resolve the memory shortage. So why not just have the OS do that automatically?

    As long as it's killing the offending process, not the proverbial drop that made it flow over. Example:

    Normal apps: 1GB
    Leaky app: .995GB and rising
    = Free space: 5MB

    Now a normal app decides to ask for 10MB space. Which process is killed?

    What I would prefer is that the OS kept system cache limited and swapping disabled until it reached a threshold value, say 90% RAM... pass 1.8GB, then you can go into panic mode, warn the user, start preemptively swapping out dead pages so we don't crash hard. But until then, don't swap. When you swap you warn, or if you know some processes are leaky, set them to "auto-killable". But I don't want the OS just kill any process that happens to make the last request.

    --
    Live today, because you never know what tomorrow brings
  136. How much is enough? by EmagGeek · · Score: 1

    My windows XP pro box started with 512MB, which wasn't nearly enough. So, I went to 1GB, and things got better, but the hard disk still thrashed from time to time. So, I went to 2GB and the system finally seemed like it was starting up faster and running more freely.

    I'm actually very glad I went to 2GB, because X-plane takes 900MB of RAM if you let it :)

  137. Swap in virtual disc drive? by Down_in_the_Park · · Score: 1

    If RAM is so cheap, why not buy twice the amount you need, set up a virtual drive and use this as a swap partition. Not really sure whether linux allows it, but it would combine the advantages of both worlds, right?

    And it shouldn't be a data safety issue, as swap isn't considered written to the hard drive, right?

    Any objections?

    --
    "People who are willing to sacrifice essential freedoms for security deserve neither freedom nor security."

    B F
    1. Re:Swap in virtual disc drive? by Burb · · Score: 1

      Yes, and while you are it, you might as well eat your own head. The purpose of swap is to give applications the illusion of RAM - in the situation you describe just don't have a swap file. Or is this a troll, sorry it's hard to tell here.

      --

    2. Re:Swap in virtual disc drive? by Down_in_the_Park · · Score: 1

      No, that shouldn't be trolling. If you define a certain amount of RAM, as the available RAM, but keep the remaining as "swap", you circumvent the copy to the hard drive, but you still have a buffer (know to the system as swap). If you start a new application, that would demand most of the "physical" RAM.

      Sure you need a lot of RAM, but that's cheap right?

      --
      "People who are willing to sacrifice essential freedoms for security deserve neither freedom nor security."

      B F
  138. None! by Sindri · · Score: 1

    My windows box has 2G RAM and turning of the swap file works very well. Windows swaps to disk weather or not it neads to, unless you turn swapping of completely (System Properties -> Advanced -> Performance Settings -> Advanced -> Virtual memory Change -> (o) No paging file -> Set).

    The computer is a lot more responsive without virtual memory, and I get no thrashing, ever!

    Using this sort of setup I recomend MemInfo from http://www.carthagosoft.net/ to be able to monitor memory usage (hitting the 2G max can be painfull).

  139. Andy Tanenbaum must be laughing by Anonymous Coward · · Score: 1, Informative

    After the demand for virtual memory in Minix drove Linus to create Linux, now people don't want to use it.

    Disk is so cheap and plentiful I now configure w/ swap ~8x DRAM so I can suspend large jobs and still start new jobs instead of having to kill the process. I also install max DRAM to minimize swapping and paging. But I'm a scientist working w/ large datasets and don't do Windows or web stuff, so your milage may vary.

    old, bearded, Unix guy

  140. 2 to 2.5 times RAM is still correct by mlwmohawk · · Score: 1

    The system *always* user virtual memory, and any tricks you try to play keep the system from using VM probably just hurt you. It has been a while since I've done any low level VMM work, but a good sized swap area allows more options on the choice of RAM to swap algoritms. Typically speaking, the system wants, AT LEAST, 1:1 RAM for swap, and more is better. Besides I hear a lot of people talking about applictions "swapping out." Applications do not "swap out" that is an old Mac-ism. In fact, virtual memory is seldom, if ever, keyed by application. On most systems VM is done on 4K page boundaries irrespective of applications, and on i386 systems, on the 32 bit linear memory space below the applications virtual machines. On Pentium II and higher, it can even be done on 4M page boundaries (but I'm not aware if either Linux, Mac, or Windows uses this feature.) Also, virtual memory is VERY fast when compared to application file access. If you have an 8m pix digital camera, your jpegs may be 3 or 4 meg, but the "in memory" version of that picture is 24 to 32 meg. Strategies to chunk up images because there isn't enough memory to load them is almost always slower than virtual memory. In short, these days, a few gigs of disk space is a $1.00, use it, your system *will* be faster.

  141. Agree with the wisdom by binary1011100 · · Score: 1

    I use linux, and I have a Machine with 512 MB RAM (please don't ask me two put another 512 stick in, because I really don't need it) I have always found when deciding what amount of space to allocate to the swap, that twice the amount of RAM, works perfectly. However physically you may be able to have as much swap as you want you've got to ask yourself, what's the point!

    --
    "I could be bought, but Linux couldn't be." - Linus Torvalds
  142. Tip: Put the swap file in RAM by Zoxed · · Score: 1

    Not quite answering your question but I read a great tip somewhere on the interweb once: as most PCs now have so much RAM you can get a big speed improvement by mapping your swap file into some spare RAM space.

  143. Virtual memory? by Runefox · · Score: 1

    If I had 2GB of RAM or more, I'd set up a 512MB RAMdisk and use 256MB of it for swap (Everything's in RAM =D). The chances of a system using 2GB of RAM or more are very, very small. As it stands, with my paltry 512MB of RAM, I never swap out unless I'm doing something with soundfonts, or I'm playing a newer game, and then I never breach 1GB unless something's very wrong.

    --
    Screw the rules, I have green hair!
    1. Re:Virtual memory? by Rob+Simpson · · Score: 1

      Heh, I actually tried something like that, but ended up just disabling virtual memory. I haven't had any problems with games or anything else.

    2. Re:Virtual memory? by C_Kode · · Score: 1

      That makes no sense. Just leaving your ram alone and disabling swap would be less overhead and the memory (both physical and virtual would STILL be going to the same place. Using a RAM disk for swap is like using your arms out the window as turn signals when your car actually HAS turn signals. It's just more work and provides nothing that you didn't already have.

      The best thing to do would be to leave the 2GB of memory alone and create some actual swap space on the disk. Chances are you will never use the swap space and if you do. Thats what it's there for!

    3. Re:Virtual memory? by Runefox · · Score: 1

      Yeah, that's fine with Linux, but with Windows, there have been reported issues with completely disabling swap. So why not set aside a small amount of RAM to keep the system happy and have a RAMDisk at the same time?

      --
      Screw the rules, I have green hair!
  144. Edited summary by massysett · · Score: 1

    "In these days, where 250G of hard disk space is not unusual, and many times is not that uncommon, does anybody care how big the swap file/partition is?"

    I've got 512MB of RAM, and Linux rarely resorts to swap. But I have a 120GB hard drive that's nowhere close to full, so there's a 1GB swap partition. Why not?

  145. Completely the wrong way round by ebcdic · · Score: 1

    The amount of swap space you need does not depend on the amount of real memory. It depends on what programs you want to run. You need enough virtual memory for all those programs. Then you want as much RAM as you can afford so that programs don't need to be paged out. More precisely, you want as much RAM as the working set of the programs - that is, the memory that is actively used.

    Particularly absurd are claims that you need *at least* N times as much swap as RAM. If you size your total VM according to the programs you run, then you want RAM to be as big a proportion of that as possible. It would make more sense to demand at least 1/N as much RAM as swap!

    (A minor point: in most current operating systems, swap is effectively in addition to RAM, so that RAM+swap must be as big as the programs you run, but in some older ones the RAM needs to be backed by swap, so that swap by itself must be that big.)

  146. None, Sometimes by noamsml · · Score: 1

    Personally, I have one gig of memory, and I barely ever go over 512 MB usage. A more "above-average" user might get up to 700, but generally speaking, the chance that people today will get to using 2GB of memory is unlikely. Thus, it may sometimes affect a computer's preformance positively to disable swap, since some programs will swap even if you're not close to 50% RAM usage (For example, I am currently using 310MB of RAM and 123MB of swap), which slows things down since it takes time to load swapped stuff into memory.

  147. /me aint no coward :P by Anonymous Coward · · Score: 0

    if you use linux, you wont need vmem at all. if you use windows, i doubt you'd need to manipulate around that, or the system will complain and adjust the vmem itself, so i guess its better to leave these 6GB of vmem.

    apart from above, i am not sure if "having lots of ram" is a good idea with windows:
    1) it will not make use of it anyways (while still ripping every last breath of your hard drive as it used to do)
    2) manipulating the registry and forcing the executables to land in ram first will eventually utilize every last bit of your (even graphics) ram and force you to reboot.

    i believe gates' followers would still do as good as they do now with these classic 640k, heh

  148. 1 gig each by FudRucker · · Score: 1

    1 gig of PC3200 DDR RAM and a 1 gig swap partition is pleny for my purposes...

    --
    Politics is Treachery, Religion is Brainwashing
  149. about 16 GB by Kaetemi · · Score: 1

    or just none at all

    --
    Kaetemi
  150. Power considerations by Sapphon · · Score: 1

    How do power considerations affect the size of your paging file? When using a laptop, for example, you'd typically want your energy consumption to be as low as possible: are you therefore better off turning your paging file off and forcing the OS to use your RAM, or letting it swap out?

    --
    Antiquis temporibus, nati tibi similes in rupibus ventosissimis exponebantur ad necem.
  151. If you need it, it's there! by abescully · · Score: 1

    My desktop at work has 256MB RAM and I typically have 200-400MB of a 512MB swap partition used during the day. (Thanks gkrellm!) The computer is an old GX200 series dell workstation with one ECC RAMBUS RIMM installed. Due to the price of RAMBUS memory and the age of my workstation, swap space is all I'm gonna get from my bosses until I get a new workstation. This just feels like the perfect argument for swap space.

  152. Swap = Mem needed for suspend by lowlands · · Score: 1

    The whole discussion is moot when you use Fedora Core 5 because you need a swap partition equal to the size of your memory so you can use the suspend/resume to harddisk functionality. If that were not the case, I'd say to hell with swap. Don't need no slow disk bringing down my laptop to a crawl. I'd much more prefer the app that's causing the trashing to shoot itself into oblivion.

  153. Witch Doctors by mlwmohawk · · Score: 2, Interesting
    The computer is a lot more responsive without virtual memory, and I get no thrashing, ever!

    Oh, please. How do you quantify "more responsive?"

    Sorry to say this, but the witch-doctory of computer maintenance is not engineering, it isn't science, it isn't even common sense

    If you get "thrashing" in your system it is because you don't have enough RAM for the applications you are using. At this stage, the application has one of two options, use user space files to reduce the "in RAM" data size or quit with an out of memory error. Most all applications, in this scenario, perform better when the OS provides virtual memory. (Obviously not all because the default swap algorithm can be a worst case, but I digress.)

    The Macintosh's early virtual memory (pre-OS/X) and old OS/2 1.x virtual memory systems really created a lot of lore about the woes of virtual memory. The reality is that the modern VMMs as implemented in the Pentiums and later are very good, and the OS support for them are excellent, and a system is almost always better off with VM than without.

    In an honest discussion it is hard to speak with absolutes, so no one can say any one way is any better than any other way 100% of the time, unless it is an obvious choice like drink poison or drink pure distilled sterilized and safe water in moderate amounts when you are thursty and have balanced electrolytes.

    That being said, unless you have a specific and quantifiable case where virtual memory hurts performance dramatically, use virtual memory, you will be better off.

  154. Two schools of thought here by Zerbey · · Score: 1

    1. "As much swap as you're ever likely to use in your environment." Which involves watching your swap usage over time and optimising it accordingly.

    2. "1GB of swap per CPU". This was told to me by a Solaris admin, and I'm still not sure what he meant by it. Solaris is particularly good at handling swap dynamically, however.

    Personally, I always assign double the RAM on the machine and have yet to run into problems. On my 2Gb VMWare box I hit about a 2Gb charge when all 4 virtual machines are hammering away nicely, with little or no slowdown (some more physical RAM wouldn't hurt a bit though, I expect). The extra 4Gb is there if something really silly happens.

    The point is, the machine has 300Gb of drive space... if I wanted more swap I could easily add it. Drive space is cheap, why risk losing a production machine to something daft like a runaway process?

  155. Re:Is swapping obsolete? (was:Rules of thumb are d by Anonymous Coward · · Score: 0

    > Or to put it a third way, is there any situation where swapping is helpful, anymore?

    Sure. As a programmer of IC CAD software I have some experience here. Our tools use large datasets: allocating 8GB is common. However, the tool uses only smaller amounts of data at a time: for example, there are four functions each using only one 2GB data structure. When they are all called sequentially, you need only slightly more than 2GB of ram. Swapping now only causes a small hickup when switching from one datastructure to another, but has hardly any other penalty. But it allows now much simpler software design, just let the OS handle the complicated stuff instead of saving the data yourself to tempfiles. And you save lots of money by needing less ram.

  156. SAN Swap? by painQuin · · Score: 1
    In this environment you are probably on a SAN and people will say to move everything there


    networked swap drives, what will they think of next!


    ... "#@$! I swapped my network driver..."

    --
    A guilty conscience means at least you've got one.
  157. Depends on the use of machine by thorkyl · · Score: 1

    Winblows machines:
    Home desktop, internet machine - 1 to 1.5 times ram
    Medium duty workstation - 2 to 2.5 times ram
    Heavy duty workstation (CAD, M$ Developers, or my case just a RAM pig) 4 times RAM

    Server(s)
    I like to set them up with 2 swaps
    first = 2 times RAM per processor on primary partition / primary drive (BSOD dumpable)
    second = 4 times RAM per processor on primary partition / secondary drive

    Linux Machines
    2.5 times RAM for workstations
    4 times RAM for servers

    --
    -- I am the NRA, enough said...
  158. I don't have the magic bullet, but... by Anonymous Coward · · Score: 1, Interesting

    ... here's what I'm currently experimenting with:
    (coming from a 256M system, and moving to a new build with 2G, win2k pro & Ubuntu 6.06 on the machine currently)

    For Ubuntu (Linux kernel v. 2.6.16) I went with a 2G swap partition, or a 1:1 DRAM/VM ratio.

    For win2k SP4 + all post SP4 updates: I'm currently just letting windows manage the VM space. On the old 256M machine, I went with a fixed 3x DRAM VM pagefile.

    Caveats: I've only recently moved to this system, and have NOT stressed them to any real degree with fully memory intensive operations. The most stressful application that has been to date on the new build has been Oblivion under win2k. The max pagefile use in those conditions have been c. 385M of pagefile use, however judging from performance that space was not being actively utilized(i.e. didn't notice alot of extraneous swapping going on judging by disk activity and pagefile usage growth(none).)

    Under linux, I can't really thinik of anything that I utilize it for that would require vast amounts of memory ATM, although I may examine building of new linux kernels and gcc from source. I expect that gcc build would be the most demanding, but suspect that, that may not even stress a system w/2G. I have no large databases or a way to generate enough use artificially or otherwise(or time or interest ATM really) see what would happen, but I strongly suspect that a swapfile around the size of physical memory may be enough, especially on systems with even more memory as undoubtedly the idea in those situations was to minimize swap space use to avoid thrashing, or even more low level swapping activity...

    Back in the day VM was great as disk space was much cheaper than physical RAM, and large VM swapfiles/partitions allowed us to run applications that may not have been able to run before. Most of these same apps now run on machines with MUCH large physical RAM installations, while using not very much more physical memory than before meaning that they can run directly from RAM which is significantly faster than swapping under VM. It would seem the best strategy is to allocate some(I like the 1:1 ratio) as applications will still allocate large amounts of space most of which will be allocated from the VM pool(reducing physical RAM size) while still avoiding swapping. In more limited(#/size of apps) systems you could probably even turn off VM, although I really don't think that it would gain you much, and each running app would have a MUCH larger physical RAM footprint as all of it's requested memory would have to be from the physical RAM pool...

    i.e. babbling aside, you'll need to do some experimentation likely with a worst load case scenario and see what sort of configuration works best for you AND how much disk space that you can AFFORD to allocate to swapfile usage. Another potential idea would be to look at limited embedded systems which just don't have large amounts of storage OR physical RAM and see what happens with those, as most embedded systems with linux that I have seen usually don't even have a 1:1 ratio of RAM & VM, usually it's a very small VM space with RAM that is several times that amount, of course this gets a little fuzzy as most embedded systems don't have anything other than some sort of RAM(flash, static, etc.).

  159. Just install a couple of these: by ?erosion · · Score: 1

    http://www.newegg.com/Product/Product.asp?Item=N82 E16815168001

    And you're set. I don't think you can get over 2GB on this model though.

    --

    I assert ownership of all trademarks and copyrights on this page.
  160. gig of RAM costs 50 times more than a Gig of HDD by da5idnetlimit.com · · Score: 4, Interesting

    And is 1000 times faster ?

    So, to answer the original question :
    Optimal amount of Swap ? 0 !

    Even my old PIII 1Ghz takes 2 gigs of ram. Newest system we have at the office takes 64 Gigs.

    => right now I consider the Linux systems @ work as having a problem if they use swap...

    Adding just a wee bit of RAM to your system and seeing swap disappear means your perfomance just exploded on this particular task...

    Best Regards,

    D.

    --
    It takes 40+ muscles to frown, but only four to extend your arm and bitchslap the motherfucker
  161. Debunked by Kalak · · Score: 1

    http://tinyurl.com/eqncw It's an old setting, not for XP for starters, and it's not very useful on the OS it's intended to be used with.

    --
    I am, and always will be, an idiot. Karma: Coma (mostly effected by .hack)
  162. Re:gig of RAM costs 50 times more than a Gig of HD by PinkPanther · · Score: 1
    Optimal amount of Swap ? 0 !
    I completely agree. The best part of this approach is that it has built-in performance monitoring for you! When the system crashes or starts throwing weird errors or denies you running new programs, etc... then it is telling you "time for more RAM".

    The alternative is to use your harddrive light as the monitor. But who ever sits there watching their hard drive light?

    --
    It's a simple matter of complex programming.
  163. Depends on apps, memory leaks and uptime by Anonymous Coward · · Score: 0

    Depends on what the systems runs and how long between application restart. I've seen crappy inhouse apps that initially only use 500m or so but if they run long enough they will use all available swap (4-16gb) due to memory leaks. A restart of the app fixes the issue but if it isn't caught you get a hung server (generally at 3am in the middle of REM).

    Generally app servers need swap>=phys memory whilst db servers are around 25% of physical memory as we have oracle/sybase servers with 96gb of ram. When we had *nix workstations they were generally 4 times physical memory but this was 128mb days.

    So I would say depends on what you're running and how long you want to run between restarts.

  164. Reasonable Limits Aren't by HTH+NE1 · · Score: 1

    what is a reasonable size for swap these days?

    Reasonable limits aren't.

    Demand always outstrips expectation, be it phone exchanges or IP addresses. What may seem like a reasonable limit at one time can prove to be too constraining in the future. That which is reasonably large at present will prove to be unreasonably small in future. So make it unreasonably large at present and you just may find it reasonably large in future.

    Though a system that can expand without limit upon demand is ideal.

    --
    Oh, say does that Star-Spangled Banner entwine / The myrtle of Venus with Bacchus's vine?
  165. What's with the stupid questions by PhYrE2k · · Score: 1

    What's with the standard help questions here today? C'mon guys- this is basics of system tuning.

    It all depends on your purpose of course. The amount of memory, what is running, etc.

    Windows requires virtual memory and still advises 2-2.5x sized RAM. Right now my 1GB of RAM windows machine has 200MB of physical memory free and 800MB of page in use while doing next to nothing. It depends on the number of programs you have in use, memory requirements of the programs and so on. If you are doing video editing with minimal RAM or using advanced photoshop plugins, up those figures. If you are running notepad exclusively, reduce them.

    Linux runs fine with zero, but the question becomes would you rather your system start killing processes or swap things out to disk if it does get a burst of memory requirements. But there's more- it will slow to a crawl if you get that spurt and start using swap.

    The formulas don't always work. A database server should ahve more memory and less swap. A workstation vice-versa. What happens if you increase memory on a database server to 16GB- should you make your Swap 40GB? Hell no- by the time you use any of that your system is fried to a halt anyway. On windows it has to be at least 16GB, but that's about all I'd do. On linux, a few GB to give it some room.

    Look at your own systems' needs and make a judgement. There is no right answer.

    -M

    1. Re:What's with the stupid questions by rcpitt · · Score: 1

      Well, aside from the subject line, I agree completely with the post - It depends.

      My workstation has 2 Gigs RAM and 200 Megs of swap - with a swap file sitting waiting for me to add it manually if I do something that actually requires swap - or do something stupid that eats it all up.

      With the small swap I get 100% reliable context switching when I move from one virtual screen to another (and I run 90 desktops on 3 screens with access to more than 20 external systems, logging, watching, etc.)

      The swap is at about 199M right now - so almost none left, but that 199M is just the stuff that really isn't actually active for long periods of time - and I've run with 10 Megs swap just fine too.

      Response is excellent - just what I want.

      On my database servers I run with a couple of Gigs on a 2 or large Gig machine - but a monitor on its use so I can tell the boss to put more RAM in and why.

      --
      Been there, done that, paid for the T-shirt
      and didn't get it
  166. Re:Is swapping obsolete? (was:Rules of thumb are d by Just+Some+Guy · · Score: 1
    Or to put it a third way, is there any situation where swapping is helpful, anymore?

    Absolutely. We have a server that processes images uploaded by our customers. It has 4GB of RAM, which is plenty for 99.9% of the workload. Every now and then, though, someone will send a really huge image our way. In those cases, we'd much rather throw some swap at the problem - even if it temporarily degrades performance a bit - than tell that customer that we can't process their work.

    Swap isn't for normal circumstances. It's for the unusual situations that you can't really plan for in advance, and is the differences between doing a job more slowly than usual and not being able to do it at all.

    --
    Dewey, what part of this looks like authorities should be involved?
  167. Lost in cyber memory by bcmbyte · · Score: 2, Funny

    Before I started this I didn't care about the answer, but now I realize that this question is as important as "Ultimate Answer to Life, the Universe, and Everything" and as I read I have realized that we humans are not powerful enough to answer this question. We should build a super computer with more VM and VA and more processors, yes, then we can ask it the question.

    Just kidding all, but it was good reading

  168. 32bit 4GB limit by arete · · Score: 1

    I'm SURE they meant the address space - they not only pointed out the kernel option possibilities, they also explicitly said a "32bit" machine. A 32 bit address space is exactly 4Gi addresses...

    If you need it, being able to use more than 4GB of RAM is the single biggest reason to get a 64bit machine - and shipping from Apple with 8GB stock for only like $10k was one of the great things about the original G5 towers, years ago. (Obviously this was loads cheaper if you bought third party RAM - the vast majority of that price was Apple's RAM markup. But, that was still cheap for a machine actually shipping with that much)

    --
    Looking for freelance Actionscript (Flash/Flex) or ColdFusion work and/or freelance developers. Email me, put Slashdot
  169. Re:gig of RAM costs 50 times more than a Gig of HD by da5idnetlimit.com · · Score: 1

    Lol

    "it has built-in performance monitoring for you! When the system crashes or starts throwing weird errors or denies you running new programs, etc... then it is telling you "time for more RAM"."

    True, that is why I still give 1 gig Swap partition to the systems, so I have some time for the replacement ram to get in.
    but my memory monitoring system is quite simple : if swap used > 0, mail the admin.

    "But who ever sits there watching their hard drive light?"

    Be carefull...This is slashdot after all ! 8)

    --
    It takes 40+ muscles to frown, but only four to extend your arm and bitchslap the motherfucker
  170. Re:gig of RAM costs 50 times more than a Gig of HD by VdG · · Score: 2, Informative

    My own perspective is from UNIX servers. As I keep telling people any use of swap/paging spaces is bad for performance so the ideal solution is to add RAM. That's not always practicable, so the real answer to how much swap space to allocate is "enough".

    I still get software suppliers, (mostly SAP AG) moaning that we've got to allocate 3.5xRAM, which is arrant nonsense. It might have been necessary years back when 2GB was a lot of memory. Now I've got servers with 10s of GBs and I really don't want to waste 100s of GBs of disk on swap space which simply isn't going to be used. Sure: disk is cheap but it all adds up. One of the larger servers I support has 128GB of RAM and 32GB of paging space, (only 1% is actually used at the moment). A few servers like that and you're saving TBs of disk space.

    Of course, if you're going to keep your swap space to a minimum you need to have good monitoring in place so that you can extend it before it becomes a problem if something unexpected happens, and it's sensible to be a bit generous about it. We do occasionally have problems when processes suddenly start writing vast amounts of data to memory but I doubt that having loads more swap space would help in those cases, as there are usually bugs in the code. Fortunately root can usually still get in, (if you're patient), identify the offending processes and kill them.

    It also helps to have an OS that makes effective use of memory. What I know best is AIX and a few years back, (quite a lot of years in IT terms!) the memory allocation processes were changed so that even if you requested an enormous amount of memory it wasn't really allocated until you actually started to use it, (i.e. put some data in there). That made a considerable difference. I would expect any modern and efficient OS to do something similar.

    Paging can be dreadful for performance as you get a multiple hit: the process that needs swapped-out pages runs slow as it waits for data to be paged in; your system as a whole also runs slowly as CPU cycles are taken up servicing the paging requests; your I/O subsystem suffers as it spends time reading and writing to/from paging spaces rather than actually doing useful I/O. It's one of the first things I always target when I'm investigating performance problems on a server, just as it was a couple of decades ago when I was doing the same things with MVS.

  171. Re:Is swapping obsolete? (was:Rules of thumb are d by MarcQuadra · · Score: 1

    I'm the guy in charge of this sort of decision on a network of about 1,200 computers and our policy this year is to set _ALL_ Windows boxes to a fixed 512MB pagefile. If someone is actually USING that much swap, I _WANT_ them to crash and have to call me so I can order them more RAM. So far the only time this has happened was in the computer lab that has Maya.

    If you're actually swapping out more than 256MB in this day and age, if you actually are executing from swap... It's time to buy more RAM.

    --
    "Sometimes, I think Trent just needs a cup of hot chocolate and a blankie." -Tori Amos on Nine Inch Nails
  172. In the old days you could control it.... by Joce640k · · Score: 2, Interesting
    In the old days (Windows 95/98/NT) you could control the maximum size of the file cache....and it really, reallymade the whole system run a lot smoother. Things like burning CDs became 1000% more reliable when you did it - you could keep on working normally while the CD was burning instead of causing a flurry of paging every time you touch the mouse.


    For Windows XP the geniuses at Microsoft removed this ability and the whole system runs much worse because of it.


    Every time you do something which reads big files from disk on XP all your apps get paged out to disk. I don't know in which fantasy world this is supposed to be an "improvement", but it's one of my favourite reasons to hate XP.

    --
    No sig today...
  173. Re:gig of RAM costs 50 times more than a Gig of HD by mrball_cb · · Score: 5, Interesting

    We've found that 512 Megs of swap is more than enough for our 2 and 4 Gig machines. Why even have swap? Here is an example:

    1) On a system with zero swap, when apache gets slammed (say you get to the top of digg or slashdot), apache starts consuming lots of memory to handle new inbound requests. When it runs out, the machine grinds to a halt because it can't allocate more and requires a power cycle. (Setting a low max children really only helps if you are happy denying traffic to the people who are trying to see your site...it's best to plan for capacity and put quite a few servers load balanced).
    2) On a system with any appreciable swap (IMHO, more than 128 Megs, up to 512 Megs), if you're monitoring the system (watch -n 1 df -h, for example) and all of a sudden it starts using swap, the machine is on the edge of dying. This gives you an early warning that maximum machine performance/throughput is occurring. You can restart apache or shut it down or similar, you can do something to temporarily lower or remove load from that machine. This doesn't give you *much* time, but it gives you some.

    In our real world experience, at digg and slashdot loads you have about 10-15 seconds to stop apache once it starts swapping. After that, the performance degrades so bad that the machine becomes catatonic, the same as #1, requiring a power reset (obviously because virtual memory on HD is magnitudes slower than RAM, as numerous others have suggested). The key here is that you must realize that some swap is good for allowing unused programs to be swapped out, such as login terminals that just sit there. It's great for detecting problems, but if your heavy app is the one utilizing swap, your machine is about to crash anyway.

  174. IMO 1GB is too much. by TheLink · · Score: 2, Informative

    I think most people who think that swap should be in terms of multiples of physical RAM are missing the point.

    How much swap you have should be related to the longest you are willing to wait for stuff to be swapped in and out.

    Adjust your swap so that your computer is as slow as you can tolerate when it runs out of memory.

    For example: if you have a typical ATA drive, random read transfers would be about 10-15MB/sec. So if you ever need to swap in 400MB of stuff, you'd have to wait about 30-40 seconds before all of it is read in.

    What complicates things is there are some applications/programs that allocate memory that they will practically never use, so you'd may want to add swap for that.

    So the swap amount would be something like: total swap = "permanently swapped out unused stuff" + (seconds willing to wait * random read speed).

    Of course virtual mem doesn't really behave exactly like that - when you are low on RAM the computer will be continously reading the program it needs in, while writing the stuff it thinks it is less important out, but basically you're kind of reliving the old days of "drum/disk memory" - where you running stuff from drum or disk. And that's really slow.

    The problem with running out of memory is that under some conditions some operating systems (e.g. Linux) can mess up and kill the wrong process to free memory. I think this has improved somewhat - but Linux used to be pretty stupid and kill pretty important stuff...

    This is mainly because of the default overcommitting of memory. With overcommit, the O/S can say "fine" even if there really isn't enough memory, but when it turns out you really do need it all, the O/S goes around looking for stuff to kill...

    If you turn off overcommit things can become safer, but you'll need enough memory to hold all allocated memory even if unused.

    --
  175. Does anyone know... by cr0sh · · Score: 1

    ...of any good tutorials and such on how to properly resize a swap partition in Linux? I am running a Mandrake 10.1 box right now, and while I have no real problems with it, I am pretty sure when I set it up I made the swap undersized, and I would like to increase it (I have 512MB, and I think my swap is either that size or maybe even smaller - I have yet to notice an issue, though). Whether using a GUI tool under X or using the CLI is fine with me, just as long as I understand the process and don't muck up my system...

    --
    Reason is the Path to God - Anon
    1. Re:Does anyone know... by Budenny · · Score: 1

      There are cheaper ways, but one foolproof way is to get Acronis.

  176. Clarifications, and appreciations by whitroth · · Score: 1

    Ok, I was the one asking this, so I see that I should have clarified:

    first, I was talking about a Real o/s (*nix), not WinDoze.

    Second, the thing that I was worried about is thrashing. As someone mentioned in their post concerning the difference between page space and swap space, page tables, that address the swap space, grow as well, and the lookups, no matter how efficient, start bogging down and adding overhead to the swap. For such reasons, too much page space can be as bad as too little.

    So, with that, I'd like to single out
    Junta (36770)
    Anonymous Coward (I use this)
    edward.virtually
    and especially
    Anonymous Coward (Read (Please!))

    for their thoughtful and useful discussions.

              mark

  177. Here's a free utility to defrag page files: by Optic7 · · Score: 1

    SysInternals.com has a free utility that defrags windows page files and registry hives, called PageDefrag.

    1. Re:Here's a free utility to defrag page files: by spyrochaete · · Score: 1

      Sweet! Thanks for the suggestion! I hate it when my SAM file gets fragmented!

  178. Re:gig of RAM costs 50 times more than a Gig of HD by mrsbrisby · · Score: 1
    Optimal amount of Swap ? 0 !
    I completely agree. The best part of this approach is that it has built-in performance monitoring for you! When the system crashes or starts throwing weird errors or denies you running new programs, etc... then it is telling you "time for more RAM".
    I use daemontools to keep services running, and enable the VMOOMK on my Linux boxes, so if I run out of memory, Linux just starts killing processes. init keeps daemontools running, which keep everything else running. As a result, it apache takes a crap, it comes back in a second, and nobody ever notices.
  179. Re:Not much, anymore... Unless you're an enterpris by Crudely_Indecent · · Score: 1

    SAP http://www.sap.com/ suggests (really, requires) 3x memory + 512MB for swap.

    Every time I fire up my development system with 2GB RAM, I see it swap. The program is a monster and requires much memory.

    Best bet is to consider the application you're planning to run. For example, if you're a video editor, you may frequently deal with files in the gigabyte size range. You may wish to use the 2.5x RAM in that instance. A business desktop user wouldn't necessarily need that much swap.

    Personally, I have 1GB in my laptop and I use 2x RAM for my swap. Yes, I've made it swap before....I was really trying.

    --


    "Lame" - Galaxar
  180. Re:gig of RAM costs 50 times more than a Gig of HD by LogicHoleFlaw · · Score: 2, Insightful

    I recently attended IBM's "Performance Tuning with AIX" course. It could basically be summed up as "Don't Use Paging Space. Ever." Then it went into lots of detail about AIX memory management techniques and the VM subsystems, with a brief foray into network performance.

    It is a very sickening feeling to go and power-cycle a production system which is completely halted due to running out of memory. Almost as bad is a system which is hitting the swap and responding like molasses.

    Look at the work you need your server to do, then put the RAM in it you need to get the job done. I've not worked with Linux in a full-on production environment, but I will go look into its systems for dealing with OOM errors. I'm sure it will be interesting.

    --
    -- Flaw
  181. Re:Is swapping obsolete? (was:Rules of thumb are d by GWBasic · · Score: 1
    Or to put it a third way, is there any situation where swapping is helpful, anymore?

    In laptops! There's actually some work being done to use flash as a hard drive cache. If it works, keeping system memory small and using more flash (with paging) could potentialy increase battery life.

    Also, remember that 2GB of RAM in a laptop can be very, very, very costly.

  182. Wow... by makomk · · Score: 1

    I never thought anyone could make Windows 3.x memory management look good (even by comparison), but you just did...

  183. Not Much of an Issue by xanadu-xtroot.com · · Score: 1
    $ free -tm
        total used free
    Mem: 249 246 3
    Swap: 250 0 250
    Total: 500 246 253


    Sorry for the ugly formatting, but you get the idea. Only 256M RAM and the same size swap and I'm not touching swap. I have OOo-calc running, and fairly large compile going, and a few other minor things and that's my stats.

    --
    I'm not a prophet or a stone-age man,
    I'm just a mortal with potential of a super man.
  184. Re:Is swapping obsolete? (was:Rules of thumb are d by makomk · · Score: 1

    Which process is killed?

    With the Linux OOM killer, the answer is "depends" - on how much accumulated CPU time each process has, how long it's been running for, who owns it, who its chlidren/parents/siblings are (and what they've been doing), the phase of the moon, ...

  185. Frequently misinterpreted rule-of-thumb by cowbutt · · Score: 1
    With the exception of some early BSD kernels that actually did swap (e.g. those used for certain versions of the Borderware Firewall, for instance) that swap-equals-two-times-memory rule was usually misinterpreted. A better way of putting it would be to say that if your total VM usage was greater than two times how much real memory you had, you probably ought to fit some more memory, otherwise your machine will thrash and performance will suck badly.

    These days, with a current Linux kernel, the only reason for swap is to page out data pages (executable pages will be just dropped and paged-in again from the original binary on disc) in order to leave more room for disc cache.

    Finally, disc is cheap these days, and re-partitioning can be a pain if one adds more memory later, so these days, I usually just make swap twice the maximum amount of RAM the system can accept.

  186. OpenOffice.org is 64-bit clean by r00t · · Score: 1

    Fedora Core 6 test 2 packages it as 64-bit.

    About the only 32-bit thing left, besides libraries, is grub.

  187. Min/Max the Same? Big swapfile = performance hit? by starrsoft · · Score: 1

    The first question is a Windows question. I read a long time ago (in PC World, I think) that the min/max pagefile/vm should be set to the same amount because Windows constantly resizes a swapfile that has a variable size and takes a lot of proc/hd/mem juice while doing so. Is this still true?

    The second question is for Windows and Linux. Does having a too-big swap file allocated cut down on performance or is the only downside the excess hd space it uses?

    --
    Read my blog: HansMast.com
  188. Always nice to have some spare by darkonc · · Score: 2, Insightful
    For me, swap space is like insurance. It's better (and often cheaper) to have it and never need it than to need it and not have it.

    Yes ram is incredibly cheap, and any amount of serious swapping is to be avoided. On the other hand, once in a while you do something stupid like having VI load a 2GB log file into RAM, or whip firefox into an 800mb frenzy and then load that 16kx32k image into GIMP, or do that database query that uses *way* more ram than you'd expected.

    In general, I'd rather have my system slow to a crawl than blow up in my face when something like that happens. At least, then, I've got the choice of what I want to kill/stop, rather than having random (critical) processes die on me and have no choice other than a post mortem.

    If you're that worried about your system slowing to a crawl when you start eating into swap space, then put instrumentation onto the system that alerts you when swap gets over 100MB. At least that way, you keep uptime and some hope of a controled recovery. With the price of hard disk storage being what it is today, it's not having a few spare gigabytes of backup VM resources that seems like a bad idea.

    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
    1. Re:Always nice to have some spare by VdG · · Score: 1

      As I said, I'm mostly dealing with fairly large UNIX servers, so 100MB of memory is beneath my notice. :-)

      It's sensible to have some leaway - even to be a bit generous - but all these old rules of thumb - 2x, 3x, whatever - are completely outdated and nosensical.

  189. Two answers by Anonymous Coward · · Score: 0

    1) none. Except in unusual circumstances, there is little reason to actually use your swap and you take a huge performance hit for using it.

    2) Lots. You may never *need* your swap but at around 20c/GB, it is pretty cheap insurance.

    I seem to recall that some older Unices and/or apps required that you had some swap even if they never used it---probably no longer the case. Plenty of swap can also keep a leaky app running much longer than it would otherwise at very little performance cost.

    bottom line: in a regular desktop system or fileserver, I would go 2GB. In a laptop or minimal system, I would allocate enough to bring my total RAM to 1-2GB depending. Then there's the special cases...

  190. Stupid by FellowConspirator · · Score: 1

    The correct amount of virtual memory is: whatever you need.

    Seriously, you ought to have enough RAM that you don't need to swap, saving that, enough to minimize it. So, use more swap that you think you will need at maximum demand. That's it.

  191. Hard disk write MB/s * 60 sec by Ant+P. · · Score: 1

    Just enough time to fix things if a process decides to eat the computer without warning.

  192. Re:gig of RAM costs 50 times more than a Gig of HD by Anonymous Coward · · Score: 0

    Some OS's coredump to swap, so having swap >= ram is essential if you want to analyze the coredump. Depending on the OS you may need some other partition to be capable of holding the dump as well (e.g. wherever /var/crash lives on Solaris).

    But yeah, depending on swap for running processes isn't generally very good.

  193. Re:heavy windows usage = 0, anything else = defaul by Fry-kun · · Score: 1

    neat!
    *takes a picture*

    --
    Did you know that "FTW" ("for the win") is a direct translation of "Sieg Heil"?
  194. Relevant by Anonymous Coward · · Score: 0

    I do tech support for schools and RAM in the PC's has increased exponentially with
    every rollout. We now have software which won't run because it's checking the virtual
    memory size, not using enough bits, and thinking there can't be anything larger than
    512mb. Every PC that has to run certain software has to be configured to have a swap of 512mb
    or we get an error saying 'I need more than 3Mb of RAM' or 'I need more than 6Mb of RAM'.
    This is Macromedia Director Player stuff, obviously not future proofed.
    In short - If you've got more than 1Gb of RAM and you're not swapping, you don't need a swap file.
    It's up to the OS though, isn't it. It should be more intuitive and realise this itself.
    How about dynamic swap files that guage the amount of RAM. amount of free HDD space, and do
    their own thing dependant on if they actually need to swap out.
    I can see the gotcha - need to swap and no HDD space. Happens already, go with the already coded
    stuff, or swap more frequently with less HDD space and warn the user HDD space is low (or get more RAM).

  195. safety margin by Steinar · · Score: 1

    You should have enough real memory in your computer to cover the working set of your programs. round up.

    Then, as a safety margin add swap. More swap = larger safety margin. 2-3 times memory is still sensible. However, as VMs are more flexible today. both 0 and 10x are possible and sensible choices for certain scopes.

    The swap should cover for some memory leaks, cover for extraordenary situations, and buy you some reaction time.
    Swap will buy you some speed with some server applications. Swap will always buy you safety and uptime.
    If you can, disable overcommit and add more swap for increased safety.

    Some swap space _use_ is OK. (and normal for a system with a long uptime.)
    However, if your computer are activly writing/reading to your swap space (more than 1% of I/O capacity) thats a sign you already are late in ordering more memory.

  196. Watching their hard drive light? Mozilla users by billstewart · · Score: 2, Insightful
    "But who ever sits there watching their hard drive light?"

    I do - any time I'm running Mozilla with a lot of tabs open and it decides to go into annoying-swapping-mode (on WinXP and predecessors) for no obviously good reason, so I've got to wait for Mozilla to swap itself in or out before I can see the web page or other application I want. It doesn't help that I mainly use it on a laptop, where the drive is slow and the RAM is a fairly large 384MB, but it also happens on my home desktop, where the drives are faster and there's 640GB of RAM, which ought to be enough for anybody.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  197. At least as much as RAM for FreeBSD and crash(8) by Anonymous Coward · · Score: 1, Interesting
    Others have already touched on the contents of tuning(7) by saying that FreeBSD's VM functions more efficiently when swap>=2xRAM. However, nobody seems to have yet thought of panics. While rare, system panics still happen on occasion (particularly in research environments, where people may be causing the system to do things it wasn't originally designed to do). If a dump device is defined (using dumpon(8)), FreeBSD will use it to save the crash dump. dumpon(8) says a swap device should be used, and not a filesystem, mainly because (in a panic situation) "the kernel cannot trust its internal representation of the state of any given filesystem....." The manpage also states that dumps typically aren't larger than the actual RAM on the system.


    So, when building a machine, I typically include a single swap partition equal to the amount of RAM plus 96MB or so. Disk is cheap, and the ability to diagnose panics can be extremely valuable.


    Note: This has worked well for FreeBSD 4.x, 5.x, and 6.x.

  198. 640K is enough... by geekoid · · Score: 1

    ...For Chuck Norris

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  199. Disk space is free - so use lots or none. by billstewart · · Score: 1
    Build a Big swap partition, and if you don't need it, then turn it off, or tune it down.


    Look, disk space is nearly free, and disk drives are Big Enough these days that you can waste however much space you need on swap. For a production environment, you don't want to waste time swapping unless something really requires it, in which case you should make sure to have all your application needs. (In an interactive server, you can play around and add swap files if you find you really need them.) So build yourself a swap partition that's at least 2x RAM, or if you're running a database or similar application that gives you some guidance about wanting more, give it more. If you think you might want 8GB, build an 8GB partition; even if you build a 16GB partition on your 160GB disk drive, it's only 10%. If you find you've got a really strange usage pattern that wants less, you'll have room to shrink it.

    16GB of disk drive costs $16, or maybe $32 on some blazingly fast Ultra-SCSI 15krpm drive. As they used to say on Usenet, your posting costs the net hundreds or thousands of dollars; you've probably spent more than $32 of salary in reading the responses and thinking about them, and you'd certainly waste far more than that by making a small partition and having to resize it to larger, whereas making it too big and then shrinking it or turning it off entirely is much less trouble.

    The real question is whether you need to put your swap on a separate spindle, or on something fast like Flash. (Yes, I know that flash has limits on how many times you can write to it, but those limits are a lot higher these days than a couple of years ago, and if $100 for a 4GB flash stick lasts you a year, you've probably saved a chunk of money compared to buying a faster CPU or more RAM or more electricity for the rotating disk drives or for the opportunity costs of making users wait. It's especially useful for reducing power-up time, though of course you're not going to have typical servers go into laptop-hibernation mode.)

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  200. Lots, or None, or Enough for Laptop Hibernation by billstewart · · Score: 1
    Disk is cheap, so if you need the stuff, you should do lots.

    But it's nice not to have to swap at all, if you've got enough RAM, and there are applications and OS's that do a lousy job of managing virtual memory; sometimes you're better off with none (e.g. if the thing's going to memory-leak anyway, then it'll use up all your virtual memory just as easily as all your RAM, so you'd be better off letting the thing choke and die early.) I get really annoyed when I'm running Firefox on Windows with lots of tabs open - if I need to do something else, and then come back to Firefox, it acts like it's decided to swap the whole thing out and needs to swap it all in again before it'll show me any pages, which is just Dog City.

    On laptops, you may need enough swap for hibernation to be able to store anything, unlike desktops where there's usually no need to be that aggressive about energy-saving, so maybe you want to have, say, 1.1 - 1.5x as much swap as RAM so that it'll be there if you need to hibernate but won't waste too much time swapping otherwise.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
    1. Re:Lots, or None, or Enough for Laptop Hibernation by richlv · · Score: 1

      btw, on laptops it would be wise to make swap for hibernation, then some - and reduce swappiness. works quite nicely.

      --
      Rich
  201. Re:Is swapping obsolete? (was:Rules of thumb are d by Teach · · Score: 1

    Thank you, thank you for not saying 'this begs the question'.

    That is all.

    --
    Graham "Teach" Mitchell, computer science teacher, Leander HS
  202. Priority of swap device by xsuchy · · Score: 1

    I'm sure you know you can assign priority to swap. When you use the same priority on swap, it behave like RAID0 (but size of partitions can be different). So piles of old disks can beat one modern disk, because total sequential rate is sum of partial sequential rate.

  203. Re:gig of RAM costs 50 times more than a Gig of HD by VdG · · Score: 1

    I hate rebooting a server to fix a problem, on principle. Usually, if we've got a memory overflow I can still get in as root but it can take a very long time, (10 minutes+ just to get past the login prompt). AIX won't often crash through lack of memory. However, as a pragmatic choice sometimes it's quicker just to knock the server on the head and reboot than to spend ages trying to log in and kill the offending processes. Better for the customer to have the application up and running than to fix it "properly", even if you have to spend a little time on database recovery afterwards.

  204. All programming is just an exercise in caching. by Anonymous Coward · · Score: 0

    Terje,
    do I recall this quote accurately? It sure has meaning today!

  205. Swap... by Corwn+of+Amber · · Score: 2, Informative

    Zero. ZERO.

    Zero swap. Buy enough ram, deactivate swap, watch your computer run as fast as it should.

    --
    Making laws based on opinions that stem up from false informations leads to witch hunts.
  206. Re:Watching their hard drive light? Mozilla users by Danga · · Score: 1

    but it also happens on my home desktop, where the drives are faster and there's 640GB of RAM, which ought to be enough for anybody.

    Whoa, you have 640 GB of RAM! I am jealous! :-)

    --
    Hey, there is only one Return and it's not of the King, it's of the Jedi.
  207. Re:Watching their hard drive light? Mozilla users by billstewart · · Score: 1

    Er, yeah, so it was 640MB. Either way, it ought to be enough for anybody....

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  208. Re:But really, who cares? I care by jedonnelley · · Score: 1

    Regarding:
    _______________
    -->My strategy generally is to use a file for swap rather than a partition, even in linux.

    What I find curious is that you have a strategy. On what relevant experience do you base this strategy? 1 GB of disk space costs less than $0.50. Set up 3 GB of VM if it makes you feel good. The latte you drink while you set it up costs more than the extra disk space!

    So go for it!!! Who cares what you do? Heck, give yourself 10x the RAM and see if it actually makes any difference!!! (it won't)
    _______________

    I have a strategy and I care. I have some 50+ rather individual servers to maintain including constant builds, upgrades, etc., etc. so even a small amount of additional administration overhead is significant (not the disk space which I agree isn't significant).

    I prefer to use swap files rather than partitions on my Unix servers (Linux and FreeBSD almost entirely). For me the main difference is that I can have an initialization script (e.g. cfengine driven) set up and even "re-up" swap files automatically vs. setting up a swap partition at build time. My "kickstart" mechanisms aren't as carefree in terms of setting up and managing swap partitions. Since I can't recall the last time anything actually swapped on any of my servers (years ago and just before a crash anyway), I don't think swap makes much difference, so I optimize for the time I have to put into getting it into place - by dealing with it in an automated initialization script and keeping it out of the issues related to partitioning the disks.

  209. Re:gig of RAM costs 50 times more than a Gig of HD by Anonymous Coward · · Score: 0

    Oh heck no! Load balanced servers SUCK like Scooty Puff JR. My hosting provider has never been the same. It was much better and faster when they just let servers crash. As now the folks hogging up all the bandwith screw us all like in a pyrmid scam. They not only over load their rack server but them all. load balancing is a suckers pyrmid scam for bandwith hogs.

  210. My expirience by Frozen+Void · · Score: 2, Informative

    I never use swap (for about six years) and had a 256MB ram machine with win98.
    Thing is i run into out of memory errors,when running alot of stuff,though rarely(windows takes 35MB by itself here).Now with 512MB i could run practically anything.

    My advice:Turn off swap,buy more ram.

  211. Re:gig of RAM costs 50 times more than a Gig of HD by Linux_Bastard · · Score: 1

    You are right about Linux systems and Swap, but I still allocate at least 20G of swap to my AMD/Intel systems.

    Think of it as your window of time to find and kill that runaway process.
    and
    Hey...the DB guys just added in annother environment without letting anyone know.

    _Using_ no swap is the ideal for performance,

    but

    _Having_ swap is nice if you like to sleep.

    That plus, if the users never suffer, they take you for granted.

    --
    F X=0:1:9999 F D=2:1 Q:((X>2)&(X#D=0)!((D>X/2)&(X'=1))) I D>(X/2) W:$X>75 ! W X,?$X+5-$l(X) Q
  212. Set your swap size to a fixed dollar amount by dlakelan · · Score: 1

    I suggest using between $10 and $15 worth of disk and then never worrying again about it.

    --
    ((lambda (x) (x x)) (lambda (x) (x x))) http://www.endpointcomputing.com a scientific approach to custom computing.