Let me complete the Table of the Elements by adding zinc. I use it daily in ZBEC vitamins.
Sometimes you can detect the onset of the upper leg cramp and a stretching exercise taught me by my physical therapists actually works for me in heading of the full cramp. Straighten out the offending leg while sitting, simultaneously point your toes backward as far as you can and bend from the waist as far down as you can holding for a 10 count. Repeat 5-10 times. It stetches out all those deep muscle groups.
Reviewing all the vocabulary taught me by my DI and riding it out is the only fix if the cramp catches me unaware. Which usually happens when the phone rings across the room or the doorbell rings.