Is it safe to clean contacts with an eraser?
It all depends on what you mean with safe.

To cut it short: if what you are doing is some sort of professional work, the answer is not at all. As @Jodes said in a comment, the right thing to do is to use some specialty chemical made for the job.

If, however, you are doing some hobbyist work and you are going to take some risks then your approach may work, but keep in mind that the results may not be very repeatable.

There are at least two things that may go wrong with your approach:


Electrostatic discharge (ESD) issues
Mechanical stress


Anytime you rub two objects against each other you have the chance of generating static electric charges on them. This phenomenon is called triboelectric effect. A problem with ESD is that it may not kill your chips rightaway (many chips today have protection circuitry that will handle a small amount of ESD), but it may degrade the performance of your devices (e.g. leakage currents or offset voltages may become permanently worse because of microscopic damages inside the semiconductor device). Therefore a RAM module, to take your example, may still work, but with intermittent failures or glitches (e.g. it may exhibit a higher error rate or it may work reliably only well below its rated maximum speed).

Whether your approach will work consistently in this respect will depend, besides sheer luck, on many parameters like ambient humidity, eraser and PCB materials, operator grounding, etc.

Mechanical stress is maybe a lesser concern, but it should be taken into account: if the eraser is hard, if you press too much while erasing, if the PCB tracks or pads are too thin, you may risk detaching one of these latter from the PCB and this will ruin your day most likely (repairing a multilayer PCB is not easy, is often expensive and sometimes is not even possible).