When it comes to slots and other hard-to-reach places on electronic boards, I often use a combination of Isopropyl alcohol (IPA) cleaner and compressed air. It is easy to damage pins inside the slot by using toothbrush or a toothpick. Just spray it well with Isopropyl alcohol, give it a gentle wipe and then give it a good blast with compressed air aiming directly into the slot. You can repeat the operation more then one time to achieve better results. You can buy both IPA and compressed air cans from ebay relatively cheap.
In regard to your idea of using WD40. I don’t advise you to do that. From WD40 page on wiki:
The long-term active ingredient is a non-volatile, viscous oil which
remains on the surface, providing lubrication and protection from
You don’t want to lubricate connectors on your motherboard. Even though multiple sources on the Internet say that mineral oil contained in WD40 is not conductive and it is often used to clean contacts in automotive industry. It is not suitable for computers. You will get problems with dust and grease buildup on oiled contacts.
I had a similar problem removing grot from an SD card slot. WD40 is not the answer! The best stuff I know of for cleaning electronics is IPA (Isopropyl Alcohol) which is the same stuff used on some screen wipes. Its great for cleaning flux from circuit boards, but also gets off grease and oil quite nicely too.
Wrap a toothpick in a layer of kitchen roll or something similar, add a bit of IPA to it and then gently rub that in and out of the socket between and on the pins – try not to go side to side so as not to bend any of the pins. You may need to do it a few times with clean bits of kitchen roll as the old piece gets grotty. Once satisfied, wait for a couple of minutes for the IPA to fully evaporate and then put the memory back in and try again.
You should probably also clean the contacts of the memory board as well with IPA/kitchen roll, just to make sure there is no residue left on that. (Observe static precautions, ground yourself while working on the electronics).
What I do is pull the board out completely and take it to my workshop where I hook my degreasing gun to my compressor, turn the pressure down to 200kPa and blow the water out.
Once it looks dry I load the gun with IPA (isopropanol as mentioned by others) and repeat. IPA is hydrophilic and will get the last traces of moisture out.
For coffee or worse cola spills I might start with the IPA, cola in particular is nasty.