Version 2 (modified by jtv, 14 years ago) (diff)


A "one size fits all" choice of swap space management was needed for our Debian-based GNU/Linux distribution aimed primarily at Thai SMEs.

Looking for a dynamic solution that didn't require a fixed swap size to be chosen up-front, we came across the well-known swapd 0.2 but it simply didn't work, even in the "improved Debian version." There is also a portable third-party rewrite (swapd 1.2) that did work, but had several shortcomings:

  • required manual configuration
  • recommended compiling a modified kernel
  • used things like malloc() in dealing with memory shortages
  • did not always check for and handle allocation errors
  • was fairly hard to maintain because of portability and C coding style
  • did not appear to have a clear, stable, reasoned-out policy
  • based on the source, seemed prone to "leak" swapfiles on disk

This eliminated swapd as an option. Another candidate was dynswapd. Written in C++, this program would not suffer from segmentation faults as allocations failed--but it still had significant drawbacks:

  • failed to catch any exceptions, so much the same effect as unchecked malloc()
  • needed C++ runtime libraries
  • contained "hidden" allocations through use of C++ standard library
  • was entirely devoid of comments and documentation: just code and copyright notices

The choice to write our own swap manager was not taken lightly; it simply seemed easier to write our own than to adapt what was already there, and facts have borne this out.