Originally posted by maradong
how to clear the ram ? it keeps beeing used even after the programs are closed ( as every flavor of unix is doing... )
I read through the thread, and there seems to be some confusion on this issue.
The ram isn't "used", in the sense that's it's actively malloc()'d by a running program (i.e., reserved and protected from use by other processes).
Just ignore the "free" and "used" values reported by top; they're misleading.
The "pagein" and "pageout" values don't refer to transfer to/from disk-based swapspace; they merely refer to the acquisition and release of memory pages, which may be from resident cached pages in physical, solid-state RAM, or it may be from disk-based swap.
It's normal for most modern instantiations of Unix (OS X is no exception) to run with very little "free" memory. This is because the pagers these days operate more effficiently by caching rather than completely freeing memory pages. Thus, when an app looks for "free" memory to report, it finds very little truly "free" memory. What is left may not be "free", but it's unused and ready to be allocated to a process if it requests it.
A more appropriate set of values to watch are those reported by vm_stat: watch the reactivated and pagein values. If the reactivated value stays constant and the pagein value starts rising steadily, you're hitting disk-based swap rather than cached memory pages, and you're short of RAM.
If you just watch the pagein or pageout values, you'll be fooled into thinking you're short on RAM when you're not.
It's only when a system is hitting the disk for memory allocation consistently -- paging memory out to and in from disk-based storage -- that you need to worry about freeing up memory by terminating processes, or increasing your RAM.
Otherwise, you're watching the normal functioning of a healthy pager in a modern Unix system.