Lifting the heel of your foot as high as possible from a sitting pasture, while keeping your toes fixed on the ground and subsequently putting it down quickly will cause the upper leg to falter violently.
If you exert yourself while you are cycling and subsequently arrest your legs, both of them will start faltering too.
If you want to speed up, while peddling along on your bike you may lose your grip on the pedals and your slipping feet get out of touch.
Stretching your legs or pulling them up, while lying down, may result in a similar faltering motion.
In stretching the additional risk of getting a cramp is implied.
It is likely to happen when you are asleep because you keep up the same posture for a longer period of time.
I try to reduce the spasms by using medicines such as (baclofen,liorisal) and I sleep on a mattress that can be adjusted in height.
I need the adjustable top part of the matress to prevent saliva getting into my lung.