Memory Error BIOS Beeps 5-1-2

When the BIOS beeps are in sequence 5-1-2, it usually means memory error indicating that the system could not find any usable memory. Computers normally require RAM memory before they will start and the self-test during system boot normally checks if any is present.
The beeps are normally associated with all of the front panel LED lights remaining lit, followed by the laptop automatically switching itself off.

On modern dell desktops, I have seen a variation of this beep code, which is 5-1-2-3. Again, it points to a failed RAM, however sometimes the problem can be with the socket on the motherboard requiring a replacement motherboard.
On modern desktops, the memory often operates at high temperatures, which can affect the soldered connections.
With increasing miniaturisation, manufacturers have to use less solder as the contacts are very close together, and this sometimes results in poor electrical contact when the socket heats up. Therefore, the problem is sometimes with the memory socket and the soldering.

Most laptops typically have a hatch on the underside of the laptop to provide access to the memory modules.

Semiconductor memory is one of the most reliable components within a laptop and it is very rare that the memory would suddenly fail.

Sometimes it is necessary to clean the contacts on the memory modules, and also the contacts on the motherboard socket where the memory module plugs-in. Obviously you should take ESD precautions to make sure that you do not damage the chip.

Memory modules often dislodge in a mishandled laptop. In the memory compartment, the clips that hold the memory modules become loose and cannot hold the modules properly. It is possible to bend the metal part of the clip slightly so secure the memory modules more tightly.

I have come across this problem on many laptops and it is sometimes due to the oxidation of the contacts between the memory modules and the motherboard, however it can also happen on desktop computers.
The oxidation is probably due to the mixture ratio of copper and gold in the contacts. More gold is better but expensive, while copper is cheaper but reacts with oxygen in the air causing a thin layer of oxidation to form after a few years.
An electrical contact cleaner and a lint-free cloth are often good enough for cleaning the contacts, which always works on most computers.