And the exercise doesn't have to be as rigorous as a marathon, the research suggests.
In the new study, middle-aged men and women who cycled or did a stretching and coordination routine for two hours weekly for six months had improvements in memory and other thinking skills.
Combining the two may provide even better results, says researcher Kirsten Hotting, PhD, a lecturer in psychology at the University of Hamburg, Germany. "I would guess that combining different forms of exercise might enhance their beneficial effects," she tells WebMD.
The study is published in Health Psychology.
In late adulthood, experts say, a region of the brain involved in memory, the hippocampus, shrinks.
Previous research has found that this region had grown a year after older adults began to exercise. That growth was accompanied by improved memory.
For the new study, Hotting wanted to focus on middle-aged adults. She evaluated 68 inactive men and women ages 40 to 56. She assigned them to the stretching program or the cycling program.
She added a group of 18 non-active people as a comparison group.
Before the study, everyone got a heart fitness test. Each of the programs were supervised and lasted one hour, twice a week, Hotting says.
"The stretching/coordination training started with a short warm-up phase, followed by stretching and strengthening of the major muscles of the whole body," she says. "Coordination exercises were balance exercises, complex movements of arms and legs, and so on. The training ended with some relaxation exercises."
The cyclists were told to exercise at their target heart rate (as determined by the fitness test) for about 45 minutes, Hotting says. They ended with a cool-down.
Before and after the study, Hotting's team measured memory and other thinking skills.
The cycling group improved their heart fitness by 15%. The stretching and inactive groups did not have noticeable changes in their fitness.
But both the cycling and the stretching groups did better on the memory test of learning a list of items than the inactive group.
The increase in this test score was linked with an increase in fitness.
The cycling group improved more than the others in the recognition test. It tests long-term retention of learned material.
One surprise finding: The stretching group actually improved more in a test of attention than did the cycling group. In a paper and pencil test, they had to find and mark certain letters quickly.
Hotting didn't find any noticeable differences in performance for any other thinking skills.
The improvements in memory are useful, she tells WebMD. "In everyday life, learning a list of items is relevant when learning vocabulary, a shopping list, or remembering to-do lists."
The recognition test reflects an ability to remember learned items for more than a few minutes, she says. "That is relevant for many things you want to remember in everyday life."
The study findings echo previous research, says Scott Small, MD, the Herbert Irving professor of neurology at Columbia University. He reviewed the findings but was not involved in the German study.
Other studies have also found that an increase in fitness is linked with selective improvements in memory, he tells WebMD.
In his own research, Small has found that inactive people who become physically active can increase blood flow to the brain. They then score better on memory tests.
One strength of the new study, he tells WebMD, is the length of the training. Another is the focus on middle-aged men and women. He says they often worry about memory problems.