To clear swap space in Ubuntu/Linux we need to use swapoff command as shown below:
$ swapoff -a
Above command will turn of swap completely.
Before running swapoff command you need to have enough free RAM available, since swapoff command will move all swap data to RAM.
If you wont have enough free RAM this command may make your system unstable.
Again to turn on swap you need to use swapon command ash shown below:
$ swapon -a
You need to have root/sudo permissions to run above commands.