Have you ever been awakened in the middle of the night because your calf is in a painful cramp? When it happens to me, I have to swing my leg to the floor to stretch the cramp out. After one cramp, I’m usually doomed to several more the same night, in the same muscle or down in my foot.

My episodes are infrequent, but they are painful. And my experience is hardly unique.

More than half of the people responding to a nationwide survey reported experiencing nighttime leg cramps. Nearly 30 percent of adults get them at least five times per month; 6 percent get them at least 15 times per month, according to an analysis of the survey results published in the journal PLOS One in June.

Study author John Winkelman, a sleep medicine specialist at Harvard University, was not surprised by the prevalence. “Not at all,” he said. “Because I see patients, I see how common they are.”

A European group of researchers queried 516 French patients age 60 or older and found similar numbers: 46 percent reported having experienced cramps, 31 percent said cramps had awakened them and 15 percent said it happened more than three times per month.

Doctors sure hear about it from patients, but they don’t have much solid advice to give. No one really knows what causes nighttime leg cramps. “As a sleep doctor, I tell patients, We don’t understand the causes, and we don’t have good, reliable treatments,” Winkelman says. (Winkelman is an adviser to a biotech company developing an anti-cramping treatment.)

That’s not to say there’s not plenty of advice out there in Googleland. Stretching regimens, hydrating and taking vitamins are some of the things that you’ll see recommended. However, the evidence is not strong for any of them.

Stretching the calves and hamstrings right before bed did yield a benefit, a small randomized study from the Netherlands found. Eighty people older than 55 had an average of three cramps per night at the start of the study. One group practiced the stretching exercises for six weeks: Its average cramp frequency decreased to one per night. The group whose members didn’t stretch reported an average of two cramps per night at the study’s end. This could have been a placebo effect from being under observation by researchers.

A small Israeli study assessed magnesium supplements in 94 adults, half getting the real thing and half getting a placebo. Both groups experienced a similar decrease in cramp frequency, which suggests a strong placebo effect.

A small study in Taiwan found an appreciable effect with vitamin B-complex supplements in elderly people with hypertension who had frequent nighttime cramping.

The list goes on, but you get the idea.

It’s not easy to study, Winkelman says. “It’s at night, during sleep — out of sight of a doctor. You can’t do a test for it.”

Also, there’s no incentive to do larger studies. That’s because the treatments that are proposed are already available, meaning they wouldn’t be profitable, and big studies are costly, says Andrew Westwood, a sleep medicine specialist at Columbia University.

One treatment that has some reasonable science supporting it is the antimalarial drug quinine.

“The best evidence is for quinine,” Westwood says. “But it’s not recommended because of its side effects.” Quinine can cause nausea, diarrhea and vomiting, as well as fever, chills and dizziness. There are also rarer but more-serious side effects, such as severe loss of blood platelets. The Food and Drug Administration has issued a warning against the use of quinine (brand name Qualaquin) for nighttime leg cramps.

Westwood came across a different idea serendipitously. Patients who had begun using continuous positive airway pressure (CPAP) machines for sleep apnea would volunteer to him that their nighttime cramps had gone away. Westwood and his colleagues started keeping track and published their case reports.

Westwood says it’s not clear why sleep apnea and nighttime leg cramps might be related. Still, he says, “now when patients tell me they have cramps, I think, hmm . . . sleep apnea?”

Nighttime leg cramps are more common in older people. They are sometimes related to such medical conditions as peripheral artery disease and diabetes. They also can occur as side effects of diuretics and some statins.

But often they just happen, without any obvious trigger. Doctors may suggest that patients try one of the treatments for which evidence is weak. “I have found in my clinical practice that trial and error works for most people,” says Richard Allen, a family medicine doctor at the Utah HealthCare Institute. “I’ll recommend one thing, and if it doesn’t work, I’ll recommend another. Eventually, everyone seems to find something that helps them.”

There’s little risk to doing stretching exercises before bed or taking B vitamins or magnesium. And they might work for you, at least a little.