The exact cause of muscle cramps is not well understood, but there are some risk factors that are thought to contribute to this condition:
1) Muscle fatigue,
2) Heavy exercising, especially in heat,
4) Over weight and obesity,
5) Electrolyte imbalances,
6) Vitamin deficiency.
Some researchers believe inadequate stretching and muscle fatigue leads to abnormalities in mechanisms that control muscle contraction. Prevention of the cramps is the best cure; for that following measures should be employed:
1) Drink water at regular intervals, even whey you are not thirsty.
2) Drink more than what you require.
3) Drink fruit juice or a sports beverage if the working conditions are hot and one sweats a lot.
Electrolyte imbalances is one of the most common and the main cause. This can be ascertained by serum electrolytes levels. Especially the potassium, sodium, magnesium and calcium are more of a concern. If cramps occur frequently, stretching exercises help. Muscle relaxant like chlorzoxazone can also help. You can consult your physician who would review your medications and medical history. Also, take Calcium and vitamin D with a supplement of magnesium and zinc.a day. Gatorade, can help as it contain electrolytes. If still the cramps persists, then you need to follow up with your doctor for a blood test to check the serum electrolytes.
Since this is happening at night it might be you sleep on your stomach or under heavy blankets. Also, you could be sometimes forcefully pointing your toes which can trigger a muscle spasm.
To relieve muscle cramps try these steps:
1) stop what you are doing
2) massage your cramped muscle with a kneading motion
3) gently stretch the muscle.
Read this resource for prevention of the night cramps;
Please feel free for your follow up questions.