Memory and swap are both near maximum. I shut down all the processes I initiated. The memory and swap are still both near maximum. Is there a way to release the memory used by a terminated program? What will happen if I turn swap off then turn it on again (sudo swapoff -a; sudo swapon -a) when memory and swap are both near maximum?
I don't remember if the Gnome System Monitor includes cache files in its memory calculation (I think it doesn't), but you can run
free -m to see the actual free memory (on the second row).
total used free shared buffers cached Mem: 7915 7180 734 134 197 4581 -/+ buffers/cache: 2401 5513 Swap: 4024 87 3937
In my case, I have 5513 MB of RAM free, which 4581 MB of it being pre-cached with files.
sudo swapoff -a && sudo swapon -a when there isn't enough RAM available will just cause the command to fail, and won't do any harm to your system.
To find out what process might still be taking up RAM, sort the column by memory usage, or use