On 23 February 2006 14:04, [EMAIL PROTECTED] wrote:
> "joaoemanuel1981" <[EMAIL PROTECTED]> wrote:
> > Do i not understand why needs swap, if have 1GB of RAM?
>
> 1. because if you have 200GB disk, cutting 1 or 2GB for swap does not
> matter

True.

>
> 2. because someone told me some apps want to allocate swap no matter how
> ram you have (I think it was someone from hp-ux support, but I'm not sure
> if this is true for linux)

This is a myth. *No* application (under linux) can grab swap space directly. 
Applications ask the kernel for memory when they allocate it. The kernel, 
based on algorithms that balance free real ram, buffers and cache, returns 
either real ram as memory to the app or - if it is low on real ram - swap 
space. So what you do when adding swap space is extending your (fast) real 
ram with (slow) memory residing on your harddrive.

>
> 3. because it is always better to have too much ram/swap then too little
Nnnnot always. There are circumstances when you do not want swap at all. 
Consider a box that has certain real time response requirements which cannot 
be met if apps are swapped out (actually parts of their code and/or data 
paged out) to the harddrive. In these cases, you do not want swap but enough 
ram to accommodate your running processes at all times.

This and 2. also mean that it's quite pointless to add swap if your 
workstation has 16GB of ram and isn't used for image processing or other 
extremely memory-hungry tasks.
>
> 4. because if you do not set up swap, but need it later, it will not be so
> easy to create it, if you partition all disk and leave no space left

The times when we couldn't resize partitions under linux without holding our 
breath are over.
 
>
> 5. because it is a good *nix habit! :-)

What does or does not constitute good *nix habits is at least debateable. 

If I needed a box that was fast at all times and (logical AND) money was of no 
concern I'd put real ram in until the bugger stopped using swap space and 
forget about swap. Since I do have to take monetary issues into 
consideration, I rather configure some (cheap and slow) swap and have less 
(expensive, compared to harddrive space, and fast) ram. How much ram and how 
much swap is an economic question.

It all boils down to how and what for you use your box. If you need more 
memory than you have ram, are you willing to invest the money for more ram? 
No? Then you need swap.

There are too damn many myths about swap out there. Like this one: Always 
configure twice as much swap as you have ram. Why? Why would I need more swap 
if I increased my ram? You need at least a little bit of swap for peak memory 
usage. Let's look at real numbers. Say, I am a bit low of ram for today's 
computers. I have 256MB ram. For peak usage, I add 128MB swap. I open so many 
applications/documents that the box starts swapping out 20MB. Sure, without 
swap space, I wouldn't have been able to open the last document. But nothing 
makes me stop there. I can as well run out of swap.

If you have 2GB of ram and 2GB of swap your total available memory is 4GB. If 
you need more you have to add either ram or swap. What you add is your choice 
based on your needs for speed and the money you are willing to spend on 
memory. That's it.

End of rant.

Uwe

-- 
Why do consumers keep buying products they will live to curse?
-- 
gentoo-user@gentoo.org mailing list

Reply via email to