If it happens consistently, remove one of the sticks of RAM and use the computer normally, then use the other one alone and use the computer normally. Usually you'll find that one stick is exhibiting the problem, and not both, if it's a hardware problem. Replace the bad stick.
Make sure you haven't disabled virtual memory.
Have you installed any drivers, for instance for USB, display, or networking devices? Try uninstalling them.
If it doesn't appear to be a RAM stick problem, or a driver issue, the next troubleshooting step is to backup your system, then reinstall OS X fresh. Install only those applications you absolutely need, then use it for awhile. If it continues to exhibit the problem, take it to apple for hardware problems. If the problem goes away, then add your applications and data as you need it, keep track of what you're adding, and if the problem starts happening again then suspect the items you most recently added as the cause.