May be make another partiton, and then do a clean install for testing purpose.
If problem fixed, it's clearly that you have a a software problem. You can move all your current stuff to this new partition as a solution. Or reinstall / upgrade your current OSX to check if it fix the problem.
If probleme persist. That may be a hardware problem. You may install only 1 piece of RAM to run the system. If ops normal, change to another RAM and repeat the test. This may let you isolate the problematic RAM module.