A charlie horse.....
Large muscles use a lot of energy to do work, and this is supplied by blood.
If the supply is not adequate their can be painful spasm; and if metabolites from heavy activity are not removed there can be spasm. Other causes can be a trapped nerve
root irritating the muscle. Some people have greater likelihood of spasm due to underlying genetic causes.