Define "all tasks". Killing every single process will make your N900 reboot. So now take your time to make a list of processes that should not be killed. Then you can easily write a script to kill all pids not in your list (plus the name to pid mapping). Plus leave the RAM management to the kernel. He knows it better than you.
ps ux