We all know that moment when you're fast asleep and all of a sudden a muscle cramp rips you from your dreams and makes you think, "this is it, this is how it ends".

Muscle cramps are both terrifying and bloody excruciating, but what are they, really?

"When we experience a muscle cramp it is usually a result of a sudden and involuntary contraction or spasm of one or more of your muscles," Robbie Clark, dietitian and sports nutritionist, told The Huffington Post Australia.

"The cramp contractions are associated with repetitive firing of motor neurons and nerve impulses in the muscle. This causes the muscle to shorten and seize up, which in some cases can be painful."

A commonly thought reason for muscle cramps is a lack of certain nutrients. While this is true, there are also various other reasons that can cause these often unbearable muscle cramps.

Prevention is always the cure. Make sure you stay well hydrated and implement good nutrition and hydration protocols around training and heavy exercise.

"It is true that muscle tissue relies, in part, on a range of minerals, electrolytes and other chemicals in order to contract and relax," Clark said.

"Some of these important substances include calcium, magnesium, potassium and sodium. Poor diet, dehydration, vomiting and diarrhoea may disturb the body's balance of minerals and electrolytes and as a result, make muscles more susceptible to cramping."

Other reasons why muscle cramps may occur include:

Muscle fatigue or injury

Inadequate blood supply to the muscle (narrowing of the arteries) e.g. atherosclerosis

Potassium

"Potassium is the major electrolyte found inside all body cells and is critical for proper nervous system and muscular function, particularly for generation of electrical impulses, which is why your muscles can cramp if you're deficient."

Calcium

"Calcium plays a crucial role in skeletal and smooth muscle contraction, including in your heart, blood vessels and intestines. It also plays a role in nerve impulse generation, so calcium deficiency may contribute to impaired muscle contraction," Clark told HuffPost Australia.