Jump to content

Memory V Swap File


astral

Recommended Posts

The swap file is used by the OS as an extension of real memory.

It was very necessary when machines only had 64Mb of memory and the OS could address 4Gb (the limit of a 32 bit machine).

The MS recommendation is to make the swap file 1.5X bigger than the memory.

That means 3Gb of disk space if I have 2Gb of memory. Isn't that a waste of disk space?

If I have a machine with 2Gb of real memory do I really need a swap file at all?

I tried configuring ZERO but Windows objected and set up 20Mb as a default.

I have upped it to 100Mb to be safe and all seems OK.

What are your experiences?

Searches in Google do not give much new information for today's big machines.

Link to comment
Share on other sites


The swap file is used by the OS as an extension of real memory.

It was very necessary when machines only had 64Mb of memory and the OS could address 4Gb (the limit of a 32 bit machine).

The MS recommendation is to make the swap file 1.5X bigger than the memory.

That means 3Gb of disk space if I have 2Gb of memory. Isn't that a waste of disk space?

If I have a machine with 2Gb of real memory do I really need a swap file at all?

I tried configuring ZERO but Windows objected and set up 20Mb as a default.

I have upped it to 100Mb to be safe and all seems OK.

What are your experiences?

Searches in Google do not give much new information for today's big machines.

hi'

I run 2gb of OCZ dual channel and no swap!

working like a charm :o

happy with this second gb :D

francois

Link to comment
Share on other sites

I also have dual channel 2GB DDR memory on my newly assembled PC.

--

OS - Win XP Pro SP2 and IE v.6

CPU - AMD Athlon 64 X2 3800+ @ 2000MHz

MB - ASUS A8N-SLi Premium w/(2x1024) 2GB Corsair DDR 400MHz

HDD - 300GB Seagate Barracuda 7200.9 16MB SATA-II NCQ

VGA - ASUS eXtreme Nvidia GeForce N6600GT 128MB DDR3

PSU - CoolerMaster Real Power 550W

Case - CoolerMaster Centurion 532

--

Would be interesting to know the answer on a optimal size of swap file.

As far as I recall, it was some info on swap file in my previous treat about buiding a new system. I will try to dig it out as soon as the time allows.

Link to comment
Share on other sites

With reference to the other topic by astral ( running out of memory: http://www.thaivisa.com/forum/index.php?showtopic=68275 ), I found the following article (at http://mywebpages.comcast.net/SupportCD/XPMyths.html ):

Disabling the Pagefile

Myth - "Disabling the Pagefile improves performance."

Reality - "You gain no performance improvement by turning off the Pagefile. When certain applications start, they allocate a huge amount of memory (hundreds of megabytes typically set aside in virtual memory) even though they might not use it. If no Pagefile (i.e., virtual memory) is present, a memory-hogging application can quickly use a large chunk of RAM. Even worse, just a few such programs can bring a machine loaded with memory to a halt. Some applications (e.g., Adobe Photoshop) will display warnings on startup if no Pagefile is present." - Source

"In modern operating systems, including Windows, application programs and many system processes always reference memory using virtual memory addresses which are automatically translated to real (RAM) addresses by the hardware. Only core parts of the operating system kernel bypass this address translation and use real memory addresses directly. All processes (e.g. application executables) running under 32 bit Windows gets virtual memory addresses (a Virtual Address Space) going from 0 to 4,294,967,295 (2*32-1 = 4 GB), no matter how much RAM is actually installed on the computer. In the default Windows OS configuration, 2 GB of this virtual address space are designated for each process' private use and the other 2 GB are shared between all processes and the operating system. RAM is a limited resource, whereas virtual memory is, for most practical purposes, unlimited. There can be a large number of processes each with its own 2 GB of private virtual address space. When the memory in use by all the existing processes exceeds the amount of RAM available, the operating system will move pages (4 KB pieces) of one or more virtual address spaces to the computer's hard disk, thus freeing that RAM frame for other uses. In Windows systems, these "paged out" pages are stored in one or more files called pagefile.sys in the root of a partition. Virtual Memory is always in use, even when the memory required by all running processes does not exceed the amount of RAM installed on the system." - Source

Link to comment
Share on other sites

I'm familiar with the XP myth page, and it seems to be mostly accurate, but I can't really agree or disagree with it.

I have 2GB of memory (2x1GB), and I usually have a lot of windows open (10-20). I do a lot of graphics and multimedia work (Photoshop and Premiere with HDV), so I do use a lot of memory. I did try turning the pagefile off, and it worked fine, even when editing complicated high-definition videos. No out of memory problems, since the memory usage usually stayed below 1GB.

However, I did have a problem when playing Battlefield 2... initially it works, but prolonged play leads to memory leakage (stuff that's left in the memory that should have been cleared) and so memory usage climbs drastically... peaking at around 2.5GB, and that's when the problems start (with page file disabled).

The beef that people have with virtual memory and the reason they want to turn it off is to reduce page swaps to harddisk. Any kind of swap takes time, be it to or from memory, since the harddisk has to be accessed to be read or written to. Now, if windows were to never use the pagefile if there was physical memory left, I wouldn't have to think about disabling it. However, even when you have tons of physical memory left, windows somehow still wants to swap out unused memory... and that leads to slowdowns. I don't know why, but it's just what I've experienced. Right now I'm thinking of getting another 2x1GB modules to max out my memory.

Link to comment
Share on other sites

If I have a machine with 2Gb of real memory do I really need a swap file at all?

I tried configuring ZERO but Windows objected and set up 20Mb as a default.

I have upped it to 100Mb to be safe and all seems OK.

Who said you need to configure anything? There's a good reason that "System Managed Size" is the default option. Just re-select it and then you can always sleep soundly: Momma Windows will take care of everything just fine.

Link to comment
Share on other sites

Trying to hide my age as best I can Windows started offering swap files way back in 1990 when the release Windows 3.0 for dos. It was designed to run on what was a massively high spec (back then) of 1mb ram and 8mb hard disk.

With a 20MB (yep megabyte) hard disk costing 200gbp and memory being more expensive MS decided to offer a way to effectively fool the OS into thinking it had more RAM than it did.

The general rule of thumb for a swap file size was actually base memory + 12 mb. The reason for the 12 mb was to take into account registry caching.

If you now fast forward to today's spec machines and the low cost of memory there should not be a need to require the RAM roll over solution of a swap file.

As the guys have said utilizing a swap file will greatly reduce your system performance as the access speeds of RAM is in the order of 10x faster to access.

If your an average (ie not doing intense graphic designer/multi media work) then 1gb+ will be enough so you can disable the system swap file.

Link to comment
Share on other sites

However, even when you have tons of physical memory left, windows somehow still wants to swap out unused memory... and that leads to slowdowns. I don't know why, but it's just what I've experienced. Right now I'm thinking of getting another 2x1GB modules to max out my memory.

How do you know that it is actually swapping, with disk accesses, and that the memory is in fact unused? What was the Memory, Pages Output/Sec reading? When?

To mitigate the placebo effect, I suggest you enlist a friend to randomly turn off or on your pagefile while you are in another room. Then, without his telling you which it is, play Battlefield 2 or whatever and see if you can tell correctly, just by using the application, whether he has in fact disabled your pagefile or not. Repeat, say, 5 times.

Have you tried the ConservativeSwapfileUsage tweak?

Incidentally, there is a pagefile logging utitlity here: http://billsway.com/notes%5Fpublic/winxp%5Ftweaks/

Link to comment
Share on other sites

The reason that I know that page swaps are occuring is that I'm doing very normal office work, and from time to time windows will access the harddisk. This is with at least 1GB of physical memory left. If you don't believe me, it's your right to say so, but I will not go through some time-consuming test procedure with a friend just to prove it to you.

As for the ConvservativeSwapfileUsage tweak, it is a leftover from the Win98 days when it was actually useful. It no longer is applicable to WinXP.

Also, as I've said before, BF2 uses massive amounts of memory and will ultimately use more memory than I physically have, and thus will use virtual memory if I enable it. If I don't, it will exit the program (after a few rounds of play) with an error that there is no memory left.

Link to comment
Share on other sites

Momma Windows will take care of everything just fine.

But I am a big boy now.

I want to be sure that what Momma says is right, and up to date. :o

Thanks to everyone for their input and links.

As the Americans say, "I will take in under advisement".

Link to comment
Share on other sites

One thing that hasn't been mentioned and that is the caching aspect of real memory. XP will try to fill memory including caching previous apps. The more memory the more apps that will be cached in it. This is why when you start a program such as Word, the first time is much slower then the 2nd time.

Some good details here: http://aumha.org/win5/a/xpvm.php

"But realize XP will create additional pagefiles if required & there's nothing you can do to stop this,

it's by design with XP. So be sure what size pagefile you really need by monitoring your pagefile size during usage & set it a couple 100MB larger.

Also make sure your memory dump is set to small 64kb dump, the only reason MS recommends a pagefile 1.5X RAM is so a complete memory dump can happen." Source

Link to comment
Share on other sites

keeping on the link mentioned by tywais:

Where do I set the placing and size of the page file?

At Control Panel | System | Advanced, click Settings in the “Performance” Section. On the Advanced page of the result, the current total physical size of all page files that may be in existence is shown. Click Change to make settings for the Virtual memory operation. Here you can select any drive partition and set either ‘Custom’; ‘System Managed’ or ‘No page file’; then always click Set before going on to the next partition.

Can the Virtual Memory be turned off on a really large machine?

Strictly speaking Virtual Memory is always in operation and cannot be “turned off.” What is meant by such wording is “set the system to use no page file space at all.”

Doing this would waste a lot of the RAM. The reason is that when programs ask for an allocation of Virtual memory space, they may ask for a great deal more than they ever actually bring into use — the total may easily run to hundreds of megabytes. These addresses have to be assigned to somewhere by the system. If there is a page file available, the system can assign them to it — if there is not, they have to be assigned to RAM, locking it out from any actual use.

How big should the page file be?

There is a great deal of myth surrounding this question. Two big fallacies are:

- The file should be a fixed size so that it does not get fragmented, with minimum and maximum set the same

- The file should be 2.5 times the size of RAM (or some other multiple)

Both are wrong in a modern, single-user system. A machine using Fast User switching is a special case, discussed below.)

Windows will expand a file that starts out too small and may shrink it again if it is larger than necessary, so it pays to set the initial size as large enough to handle the normal needs of your system to avoid constant changes of size. This will give all the benefits claimed for a ‘fixed’ page file. But no restriction should be placed on its further growth. As well as providing for contingencies, like unexpectedly opening a very large file, in XP this potential file space can be used as a place to assign those virtual memory pages that programs have asked for, but never brought into use. Until they get used — probably never — the file need not come into being. There is no downside in having potential space available.

For any given workload, the total need for virtual addresses will not depend on the size of RAM alone. It will be met by the sum of RAM and the page file. Therefore in a machine with small RAM, the extra amount represented by page file will need to be larger — not smaller — than that needed in a machine with big RAM. Unfortunately the default settings for system management of the file have not caught up with this: it will assign an initial amount that may be quite excessive for a large machine, while at the same leaving too little for contingencies on a small one.

How big a file will turn out to be needed depends very much on your work-load. Simple word processing and e-mail may need very little — large graphics and movie making may need a great deal. For a general workload, with only small dumps provided for (see note to ‘Should the file be left on Drive C:?’ above), it is suggested that a sensible start point for the initial size would be the greater of (a) 100 MB or (:o enough to bring RAM plus file to about 500 MB. EXAMPLE: Set the Initial page file size to 400 MB on a computer with 128 MB RAM; 250 on a 256 MB computer; or 100 MB for larger sizes.

But have a high Maximum size — 700 or 800 MB or even more if there is plenty of disk space. Having this high will do no harm. Then if you find the actual pagefile.sys gets larger (as seen in Explorer), adjust the initial size up accordingly. Such a need for more than a minimal initial page file is the best indicator of benefit from adding RAM: if an initial size set, for a trial, at 50MB never grows, then more RAM will do nothing for the machine's performance.

Bill James MS MVP has a convenient tool, ‘WinXP-2K_Pagefile’, for monitoring the actual usage of the Page file, which can be downloaded here. A compiled Visual Basic version is available from Doug Knox's site which may be more convenient for some users. The value seen for ‘Peak Usage’ over several days makes a good guide for setting the Initial size economically.

Note that these aspects of Windows XP have changed significantly from earlier Windows NT versions, and practices that have been common there may no longer be appropriate. Also, the ‘PF Usage’ (Page File in Use) measurement in Task Manager | Performance for ‘Page File in Use’ include those potential uses by pages that have not been taken up. It makes a good indicator of the adequacy of the ‘Maximum’ size setting, but not for the ‘Initial’ one, let alone for any need for more RAM.

The question I would like to ask is abaout the need to use the disk fragmentation (both for the paging files and conventional defragmentation), see here:

- http://www.sysinternals.com/Utilities/PageDefrag.html

- http://www.sysinternals.com/Utilities/Contig.html

Link to comment
Share on other sites

I use a program called "Diskeeper Professional" to handle file, pagefile, and MFT table deframentation. For the last item I mention here is an excerpt from the help file:

"MFT Defragmentation—defragments the Master File Table (MFT). The MFT is a critical section of Windows NTFS disk volumes. The MFT is used by the NTFS file system to locate files on a volume, so fragmentation of the MFT slows the retrieval of files on the disk—whether these files themselves are fragmented or not. Defragmenting the MFT will improve the overall performance of the volume.

Note that on Windows XP and Windows Server 2003 systems, most, but not all of the Master File Table can be defragmented by Diskeeper online during normal Set It and Forget It or manual defragmentation operations. The boot-time process is still required to fully defragment the MFT, but it usually does not need to occur as often as it does on Windows NT and Windows 2000."

Link to comment
Share on other sites

The reason that I know that page swaps are occuring is that I'm doing very normal office work, and from time to time windows will access the harddisk.

Which doesn't mean that page swaps are occuring and, even if they were, surely aren't slowing down your very normal office work.

Link to comment
Share on other sites

The question I would like to ask is abaout the need to use the disk fragmentation (both for the paging files and conventional defragmentation), see here:

- http://www.sysinternals.com/Utilities/PageDefrag.html

- http://www.sysinternals.com/Utilities/Contig.html

Defragging is good to do now and then--say, once a month, though with modern NTFS systems it is not needed as much as in the old FAT32 days. Professional defrag packages can handle the paging file as well. But normally a pagefile defrag has to be scheduled for a reboot. I use the sysinternals PageDefrag, since it's free and you can tell it to run on your next reboot and it does so without using its own scheduler, which means one less program running in the background. I run this and all my maintenance programs from their commandlines using one system scheduler.

Link to comment
Share on other sites

It would be nice if people were to realize that whatever they may have experienced, it is good to keep an open mind, and that others may not have experienced the same thing. It is also wise to keep in mind that the information given on the internet is not always 100% correct or verified, and that it comes from people who usually take that information from other people, and probably have never bothered to check whether it is actually valid.

Also, while some things may work for one person, those same things may not work for others. There is no product/method that does everything well for everybody.

For Astral, if you're not using any memory-intensive games, it's probably safe to go ahead and "disable" the page file (it's the option at the bottom... don't set it to zero, it won't allow that). I've done it, and was able to work without any problems (not play BF2, but work).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.








×
×
  • Create New...
""