Why use swap when there is RAM free?

Derek Broughton derek at pointerstop.ca
Sun Aug 16 17:28:08 UTC 2009


Chris Jones wrote:

> 
>> _You_ might know you'll need it.  The swapper doesn't.  Many pages that
>> end
>> up in swap might never be used again.  I remember, in the days when we
>> had to worry about such things, on VMS I had a way to mark pages as
>> discardable - so that code or data only needed at startup could be just
>> deleted rather
>> than swapped out when the memory was needed by something else.  Even if
>> Linux has this capability, I suspect most programmers just wouldn't
>> bother with it.
> 
> Hmm, maybe I miss the point but why not just free() the memory back to
> the system once your code is finished with them ? Surely thats the
> cleanest way to deal with this...

It's not cleaner than having your code and data in blocks that are 
automatically freed, but otherwise essentially the same.  You still have to 
manually separate those pieces of the program from the ones you can't free - 
and then you have to free() it - and I suspect that it rarely gets done, 
except with apps that use huge amounts of memory.
-- 
derek






More information about the ubuntu-users mailing list