It can also be from lack of exercise. Be sure to stay hydrated, and walk, swim, dance, something to work your muscles :)
I'm the same only seems to happen in pregnancy for me. Its lack of salt. If crisps don't give you indigestion then I'd recommend a pack of ready salted crisps an hour before bed. Last night my husband massaged my calf muscles and feet for just a few minutes and for the first night in weeks I slept through. I had been woken up 4-5 times a night in agony with cramps where walking it off was the only fix. I can't eat crisps in this pregnancy cos of indigestion but I'm doing the massaging again tonight - it was sooo effective!! Good luck xx