If your system is more recent, you may find that the memory test begins automatically; the newer interface has a grey or black background.
You may find, additionally, that the diagnostic function has been removed from your system; this sometimes happens when you format the hard drive and reinstall OS X. If holding down D isn't bringing up the testing screen, try again and this time hold down Option + D, and your Mac will look online for a set of tests it can download.
Wait for the tests to complete, and your Mac will tell you about any problems with the memory.
Third-party RAM checks
For further confirmation, you can turn to third-party RAM checkers. We recommend that you try more than one and compare their results, because one program may miss a problem that another can detect.
One of the most popular memory-testing utilities is memtest, which is free and runs from the Terminal command-line. But running a search for 'RAM' on the Mac App Store will bring up a number of options. Remember to check the reviews to find something reputable.
We recommend that you run the RAM checks in as stripped-down an environment as possible: you want to make as much RAM available for testing as possible. At the very least you should close down every other app, but a better solution is to use Safe Mode (hold the Shift key while booting) or Single User Mode (hold down Command + S) - whether you'll be able to use these modes will depend on the RAM check program you're using.
How to test for bad or faulty RAM on a Mac: How to replace the RAM in your Mac
If repeated tests indicate that something is wrong with your Mac's RAM, it's time to do something about the problem. On certain models of Mac (but not many, these days), you'll be able to access the RAM modules: if so, and if you're up for the slight effort and minor risks involved in doing so, you can buy some new RAM and pop it in yourself.
We talk you through this process, as well as discussing which models of Mac allow the user to access the RAM, in this article: How to install extra RAM in a Mac.
Sign up for CIO Asia eNewsletters.