The linux memory management basically tries to employ all possible memory. The "free" space is continually used up as buffer caches in an attempt to be efficient. This grows over time BUT as new process need more memory and as the free pool dwindles, the memory manager will return the buffer cache as needed. Thus you see perhaps a fraction of the memory being released when you terminate some processes. This buffer caching does not lead to an out of memory condition however.
Question: are you using a 32-bit or a 64-bit linux version. If you are using a 32-bit version, then it is possible that one of the apache processes of mysql bumped into the 2GB process memory limit and thus reported out of memory. This is just a guess however.
Are you running other things other than apache and mysql that could be taking memory. Some badly coded java apps have been leakers as well. It is not clear again that any of your other process could be causing a memory problem.
Some investigation into the system, mix of processes, mysql configuration parameters could be in order.
BTW, I understand that you can flush the buffer cache using the following command (as root):
sync; echo 3 > /proc/sys/vm/drop_caches
However, this is not really something I'd recommend you do in a production situation but might be interesting in a testing or benchmark environment.
Hope this helps.