Wikipedia
Heat cramps, a type of heat illness, are muscle spasms that result from loss of large amount of salt and water through exercise. Heat cramps are associated with cramping in the abdomen, arms and calves. This can be caused by inadequate consumption of fluids or electrolytes. Frequently, they don't occur until sometime later, especially at night or when relaxing. Heavy sweating causes heat cramps, especially when the water is replaced without also replacing salt or potassium.
Although heat cramps can be quite painful, they usually don't result in permanent damage, though they can be a symptom of heat stroke or heat exhaustion. Heat cramps can indicate a more severe problem in someone with heart disease or if they last for longer than an hour.
In order to prevent them, one may drink electrolyte solutions such as sports drinks during exercise or strenuous work or eat potassium-rich foods like bananas and apples. When heat cramps occur, the affected person should avoid strenuous work and exercise for several hours to allow for recovery.