I've read that, like the stich, no one is really sure what exactly causes the leg cramp (superb!), but generally it is just an involuntary spasm of muscles in your leg (which is...rather painful). It's pretty well known that strenuous execise causes cramps, but these conditions can also:-

Not drinking enough water a day
Long periods of inactivity (does sleep count?!)
Not having enugh calcium (milk, cheese) postassium (bananas & dates) or vitamin E (spinach, broccoli)
Thyroid problems

and well, there we go! The general conclusion probably being that you're going to get a cramp sooner or later in your life, and when you do, it's going to hurt Btw, if you think legs cramps are bad, neck cramps are death without passing into the next realm!