the best solution against this is not allowing physical access for untrusted people to your hard disk, or, if that's impossible, not using swap partition or using an encrypted swap partition (linux does not have these, but some bsd systems do).)
AFAIK, you *can* encrypt even the swap using kernel 2.6 (don't know about 2.4).
Below are some pointers, surely there are others floating around on the net.