The general reason for foot cramps while sleeping is decreased circulation in the foot. The drop in oxygen to the foot muscles causes them to constrict or spasm, sometimes painfully. Foot cramping can happen at any age. Modern lifestyles with a lack of proper exercise is sometimes blamed for foot cramps, but even athletes suffer from foot cramps.
Electrolytic imbalance is a major factor in foot cramps. There must be a proper balance in the salts of sodium, potassium, calcium and magnesium. A dip in potassium is the chief culprit for stopping the proper electrical signals from being transmitted to your muscles. (Runners often will have a banana before a race because of the high potassium level.)
Lack of hydration is another reason for foot cramps. With athletes, the loss of potassium comes about partly through dehydration and sweating. Sports drinks are designed to help keep up hydration and electrolytes in athletes. For the person wanting a sleep uninterrupted by foot cramps, proper hydration should do the job because loss of salts through sweating shouldn't be an issue.
Overexertion of foot muscles, resulting in inadequate circulation and potassium levels, can also be the culprit. If you have walked an unusual amount before sleep, foot cramping can result. The circulation and cramping problem may also plague those with specific health issues, such as diabetics.