How big SWAP do I need?

Hi,

I’m trying to move the entire content of current disk (all partitions) to a new bigger one, with gparted. Therefore I thought of increasing swap partition if necessary. Now it is about 2 GB and amount of RAM I have is 4.5 GB. I heard that the size of swap should be twice the size of RAM, I my case that would be something around 9 GB. The OS I have is suse 11.1 with KDE 4.2. Can you please suggest the most optimal size of SWAP I should have. Thanks for your help.

if you’re going to use suspend to disk, make swap at least as big as the amount of your RAM, preferably a little bigger. If not, you’ll be fine with only 1 GB

To be honest i’d say something else:)
I’m on my mother’s PC right now that has 512 MB of memory and it uses right now something like 50MB of swap :smiley: SWAP is set for 750MB and it NEVER reaches more than those 50MB.

Again, consider using swap for hibernation (if you don’t have any problems with electricity in your place then just use suspend to ram, faster and you don’t need swap :slight_smile:

Also, having more than 2GB of memory it is not necessary to use swap unless you want hibernation :slight_smile:

I suggested 1 GB swap (if no need for suspend to disk) to have more headroom, just in case. In your case with 512 MB RAM, fire up Vuze with a few torrents, fire up a few more heavy Java apps and see after some time if you’ll only use 50 MB of swap. I bet you won’t :wink:

EDIT: I also have an old P4 with only 512 MB of RAM and running Vuze with 4 torrents, KDE4.2.4, Firefox with 5 tabs open and a local webserver consumes ~250-300 MB swap after some time

It may be true, but i use for torrents ktorrent which is far less memory hungry than Vuze. Besides my mother’s pc is a crap celeron that is choking when starting firefox so i’m not even talking about firing up something that is CPU heavy :slight_smile: Anyway, 4.5 GB of memory is sufficient to run without SWAP but if You need some to being safe then have a 1GB swap and you won’t even see it being used at all :smiley:

On my personal PC i got 8GB memory and swap was never seen on my PC :smiley:
Only stupid windows was using swap (XP, Vista and Windows 7) despite the memory amount, plain stupid…

P.S. Oh yes, Vuze is HEAVY, firing up just the Java virtual machine takes at least 200MB of memory which is a god **** waste thus i prefer ktorrent :slight_smile: I’d use Vuze IF there was a feature that no other app provides but since i get everything i need with ktorrent and aria2c then i’m perfectly happy. Also i hate wasting memory, even having 8GB i hate see it use more than necessary.

Still, it’s better to have a bit more headroom than to unexpectedly come to a point where you might need it but don’t have it. 1 GB in his case should be enough, just in case. Yes Vuze is ****. The only reason why I use it is because ktorrent does not provide support yet for level1 IP blocklists which are compressed in gz format. ktorrent only supports zip currently so if I want to use the level1 file, I’ll have to download it, un-gz it and load it in ktorrent, but this means that I’ll get no automatic updates of that file so I’ll have to perform the downloading, unzipping and loading of the level1 file each time manually. Not so with Vuze. I raised the issue on the ktorrent forum and hopefully the devs will add support for gzipped files. Then I can completely drop the pig that is Vuze. It was in the past such a great torrent client, but sadly, has become cr@p over the years. I can just use transmission, which supports level1 gzipped files and automatically downloads them, with the kde4 interface plugin but this one lacks file preallocation which I always use to minimize fragmentation. Without preallocation, on ext3 (even on xfs sometimes), copying the finished torrent to some other place is slower as I have experienced many times

You never tried to make a simple script to download that gz file, unzip it where You want it and let ktorrent use it??
I guess the script would be plain simple, you’d have to put it in the cron folder and off You go, launch and forget:)

KDE 4 has a nice cron module which sits in the system settings. It would be simple as making it download that file every couple of hours with wget for example, another script to unpack it and another to move it to your desired location :slight_smile: and You can stop using Vuze.

No, I never wrote such a script and won’t as Vuze works for me so I use it. Still, it’s really stupid for ktorrent to support zip but not gzip, which is much more used on Linux than simple zip, and of course, the level1 file is gzipped. I already mentioned that on the ktorrent forum

Thank you all for your suggestions :slight_smile:

I always thought so, it makes a lot of sense (swap = RAM).

However I recently upgraded a 1GB RAM / 1 GB swap laptop to 2GB RAM, and it still suspends to disk!

With 2GB RAM all non-cache data in memory is usually less than 1GB, and if fits into swap. After resuming KDE’s memory monitor shows 1GB of RAM used (data + as much cache as still fits) and 1GB (100%) swap.

This is a very smart kernel :slight_smile:

About the original question, in a number of machines I care for:

1GB RAM -> moderate/heavy swap use, 2GB feels like a good swap size.

2GB RAM -> light swap use, 1GB swap is more than enough, not considering suspend2disk.

4 GB RAM -> I have yet to see any swap use, even with one VM also running.

Of course, your requirements may vary.

Correction: … and an empty (0%) swap.

I would use anywhere between 1x to 2x ram in swap. Unless you have a lot of RAM and almost no disk space, that is a safe amount. Using Hibernation, pretty much always pick 2x ram.

On another note I noticed OpenSUSE hibernates/resumes almost 2-3x faster than Red Hat/Ubuntu. Although Ubuntu Jaunty boots faster.