2

I have 4GB of ram, and an 8GB swap partition available.

Sometimes I like to see how much memory is used at particular points. And I noticed, that sometimes there is small amounts of swap used (~200kb), although the real memory I have not seen exceed 1GB ever.

Of course I realize that this is not an issue most of the time, as 200kb is like a glass of water in the ocean.

Is it just a reporting error? Cause once I was running Ubuntu from livedisk, and it was showing that it was using a lot of swap.. but when you run in livedisk Ubuntu wouldnt have swap available? (or at least you'd hope it wouldn't just start writing stuff into a hardrive og host PC?). Although there was a swap partition in that machine, could livedisk use it??

galdikas
  • 227
  • 1
    When there's a swap partition available, live systems can (and often will) use it – knittl Mar 02 '13 at 14:06
  • ok that answers that part. Now.. why would live/native system would go near swap, if there is >3GB of real memory available? – galdikas Mar 02 '13 at 14:24

1 Answers1

3

That is a design feature built into the kernel itself. In Linus (Torvalds) we trust!

You can try to adjust some of the behavioral characteristics, but on a low-level, the kernel only considers them suggestions. (google 'swapiness')

Often times, swap can be assumed to reside on hard memory. If a program wants a little extra protection from crashes it might request a temp file be synced to disk (which could end up on swap). Then after a crash, a dirty swap can be detected and some data recovery attempted.

You might be surprised how frequently small amounts of data are written to swap (attempt to mount your swap on an old USB drive and you will feel the pain when it starts blocking!)

user2097818
  • 146
  • 3