I tend to get them when I'm way too relaxed as that makes me "stretch out" during sleep, which I kinda notice in half-sleep as feeling great, until I seemingly "overstretch" and get fully woken up to a painful calf cramp.
Tho that whole problem kinda fixed itself once I started taking Magnesium supplements before going to bed, to help with teeth gnashing/neck pains.