LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   A swap partition so be how big? (https://www.linuxquestions.org/questions/slackware-14/a-swap-partition-so-be-how-big-116962/)

skeetnah 11-17-2003 05:30 AM

A swap partition so be how big?
 
Two times your RAM? In my case:

swap = 2 * 512
swap = 1024

I currently have my swap set to 1024... Too much? Too less? Just right?

a slacker 11-17-2003 06:02 AM

Thats exactly correct. It should be 2x your physical RAM

skeetnah 11-17-2003 06:22 AM

Whoops, I didn't notice the post a couple down asking nearly the same question! Sorry!

nvn 11-17-2003 06:55 AM

The idea of the recommended swap size being about 2 - 2.5 times the RAM is not appropriate unless you're using a very old computer with not very much RAM. Also, that recommendation is very Windows-ish...unless you're doing, say, heavy video or audio editing, it's just a waste to set the swap that big in Linux. If you did...check the percentage of the swap file being used. You might be surprised. ;) In my case (1024 MB RAM), I have yet to see swap utilization which exceeds 0.0%.

LoungeLizard 11-17-2003 07:26 AM

I agree with nvn if you have 1024 ram you need very minimal swap ie: none or at the most 256. I have 1024 RAM and I have my Swap set at 128MB and I have never once touched my swap space.

mrpdaemon 11-17-2003 07:39 AM

512MB RAM 256 MB swap here , using at most 5% of the swap space.

However, if you do programming using dynamic memory allocations and tend to forget freeing stuff (like I do ;) ) you really wish you had much more swap space :)

In the other side, using memory profilers save the day :D

ringwraith 11-17-2003 05:01 PM

I think one needs to be cautious in just saying you don't need swap anymore. At the time of Slack 8, Linus T himself was still saying you needed 2x Ram. The kernel underwent some changes that may have changed that need, where less was needed. In reading some of the notes on 2.6, there is discussion of what is in RAM during a crash being saved to swap. In that case swap would need to be at least as big as RAM.

deceasedcomrade 11-17-2003 06:14 PM

Noticed this discussion and im wondering, for my instal of slack 9.1 on my computer with 786MB of DDR how big i should actually make my swap, i was gonna make a partition for it but i dont know if i want to if it'll go to waste (i hate being wasteful with space and not planning properly) So if i were to just not make a partition would it make any sort of difference? i doubt i'd notice that much because i dont plan on using slack as a primary OS, Im still in highschool and of course my web design teacher cant make a page work in anything but IE.
Anyways if i just make one partition for slack and just keep the swap with the root and home and everything in a single partition would that be ok? or is that just a no no?

DaOne 11-17-2003 09:01 PM

Hmmm...I use 1024MB of RAM, and have no real need for swap. I have to agree with nvn here.
Now if you have 512 or less, a little swap partition wouldn't hurt...say 256-512MB???
My 2cents...

e1000 11-17-2003 09:28 PM

I only have 192 megs of ram, after trying bloated redhat and seting my swap at 400mb and still using very little swap, i installed slackware with only 100mb swap, and I'm keeping the WM light (fluxbox).

I have yet to see over 1% being used, anyways, I can always back up and resize my "/home" partition if I ever think i need more swap; for say, apache or something. but I guess thats the benefit of using many partitions on an install (although realistically I only have /, /home, and swap)

fyoder 11-17-2003 10:57 PM

Did a google search on the subject and came up with an old but very interesting page. It goes into the history of the 2x rule.

Quote:

That RAM to swap ratio thing, was an old Berkley-ism.
The older Berkley-based kernels (like SunOS 4.x and
before) would actually load the application into
memory and swap. The 2X+10% rule was to ensure that
the kernel had enough room to work with.
and although it doesn't mention Linux, I think the following applies:

Quote:

The total amount of virtual memory (physical memory
and swap) required for a machine is dependent upon
the cumulative memory requirements of all processes.
When you run out of virtual memory, new processes can
not be started and running processes that execute
'mallocs' will fail.

Obviously, it is necessary to size the machine with
sufficient virtual memory capacity to avoid this
condition; however, the ratio of physical memory to
swap space required for reasonable performance is
completely dependent upon the characteristics of the
applications. If the processes use large amounts of
memory that is 'active' (i.e. frequently updated or
referenced), then a high ratio of physical memory to
swap will be required to deliver consistent
performance. If, however, the applications use large
amounts of memory, most of which is inactive,
then reasonable performance can be achieved with a
smaller physical memory to swap ratio. 'Rule of
thumb' guidelines for memory/swap sizing are useless
because the system requirements are completely
application dependent.
A bit technical, but an interesting read none the less.

http://www.netsys.com/sunmgr/1998-03/msg00073.html

Personally I have a half GB of RAM and a swap partition of the same size even though the only times it has come close to being full was when I ran a program that probably had a memory leak, and when I wrote a perl script that deliberately tried to fill it.

I read an account of a gentoo user's attempt to install kde and how he succeeded when he used 400MB swap to supplement his 64 MB of RAM, so there are circumstances when big swap is useful, though I forget what his original swap was. If he was using the 2x rule then I guess it would have been 128MB. Perhaps he could have been successful with something less than 400MB but more than 128MB.

The real question is 'how much memory do you need, preferably allowing for a margin of safety?'. Ultimately that can only be answered by experience, since people have different usage patterns. There's no 'one size fits all' rule. That said, if you have a GB of RAM you probably don't need a 2GB swap.

deceasedcomrade 11-18-2003 12:02 AM

Well my question is, how does windows actually determine its swap size apart from nessicity? it's worked for me so far, before now i never had to worry so im not gonna. occasionally when im not on my awe inspiring computer i've gotten that message about windows increasing the paging file size, if thats the only time it makes changes then how does it figure the page size? does windows use x*2=10%?

J.W. 11-18-2003 07:37 PM

Personally, my experience has been that if you've got 256Mg or more of RAM, it's unlikely that you would be using swap to any significant degree. As others have stated, the "twice RAM" guideline is a legacy of the days when having (for example) 64Mg of RAM was considered a totally bitchin rig. Obviously it doesn't hurt to create a big swap space, but unless your usage actually warrants it, you probably are just wasting disk space.

My recommendation would be to allocate a max of 256Mg for swap, regardless of how much memory you have. -- J.W.

discostu 11-19-2003 10:38 AM

Limitation on RedHat 8.0 swap?
 
Hi all - I have a box with 4 GB of RAM. I understand there is a limitation to the size of a swap partition on RedHat 8.0 of 2 GB, but it appears as though I cannot add more swap partitions to create more than 4 GB of swap. I know this may seem insane per your discussion, but the apps that my co-worker ASIC engineers are running on this box actually have failed with 4 GB of ram and 2 gb of swap, claiming a lack of memory (this could be the tool version's fault, not the OS)

I added a 2 GB swap partition and that bumped up the total swap space to 4 GB, but when I add another 2 GB swap partition, it bumps down to 2 GB of total swap - why?

I might be missing something obvious, so I thought I would ask. Any info is greatly appreciated.

Thanks

Misel 11-19-2003 10:56 AM

256MB Ram and 128MB swap here - never had a problem while using this laptop for coding (C and Websites) or usual office stuff and a little GIMP.

As for your problem, discostu. I couldn't really follow how much swap you know actually have but you do know that 4GB Ram is the upper limit for 32bit processors unless you enabled PAE in your kernel. Look in the kernel config in the "Processor features" under "High memory support" whether your kernel can handle up to 960MB, 4GB or 64GB of RAM.


All times are GMT -5. The time now is 03:46 AM.