I started to type a reply, but then remembered:
And Dr. Lynne:Although its supposedly common knowledge that low electrolytes or dehydration are culprits, it seems a lot less is known than previously thought. See for example: What causes leg cramps? - Scientific American
However, most folks seem to agree that conditioning does play a part.
Personally, for prevention of common calf cramps in scuba, my best regimen has been calf raises and, as 00wabbit suggested, finning.
Additionally, many of us have found that different fins help. For me, Force Fins work best.
I'm so glad to see knotical's link, supporting the position I've held on these threads for years, which is that electrolyte imbalances are RARELY the cause of scuba-related cramping.
The first thing you always see on these threads is a whole bunch of people blaming dehydration and potassium deficiency, but it just isn't common to have significantly low potassium in an unmedicated adult eating a normal diet, without any vomiting or diarrhea.
The article confirms that stretching is one way both to alleviate cramping and to prevent it. Conditioning the muscles you are using is another. HERE is an excellent article on muscle cramps in divers.