On Saturday 20 August 2005 14:06, Anders Johansson wrote:
On Saturday 20 August 2005 14:53, Robert Paulsen wrote:
Both are good ways of seeing if the kernel thinks it has swap available, but I suspect the only way to see if it's actually working (as in 'no bugs') is to actually allocate enough memory that the kernel starts swapping. A small program that does nothing but allocate memory wouldn't take many seconds to write
It's a little more complicated than you might think
The program you link to looks interesting and useful. But it wasn't what I was talking about. I was talking about allocating memory just to see if the system actually is able to use the swap it claims to be. This is a 5 second job. This program you point to does more than that.
Simply allocating the memory does not cause the swapper to be used. Each page of the memory must be also touched. Then, there will still not be much activity if the memory is not touched repeatedly, especially if you want to see both swap in and swap out. You will also see different behavior depending on whether or not the memory is freed and re-allocated. These are all things the program allows you to control, in addition to the other non-memory related stresses it can induce. If you simply allocate the memory you will not be able to observe any swapper activity -- and that was the point of the exercise: to see if the swap system was "working".
But it looks very interesting, and could probably come in handy as a base for a benchmarking tool