It sounds like you may be experiencing Charley
horses (which are muscle
cramps/ spasms) at night. These can be caused by a number of things including dehydration, low potassium, low calcium or low magnesium levels, or overuse or injury to the muscle. Charley horses are very painful. When you start to feel the pain you could try and alleviate it before it gets bad. You can massage the muscle, apply heat first and then ice once the cramping stops, NSAIDS such as ibuprofen can be helpful.