Being physically fit may sharpen the memory and lower our risk of dementia, even if we don’t start exercising until we are middle-aged or older. But some exercises are better than others in this regard.

That’s the takeaway from two studies of the interplay among exercise, aging, aerobic fitness and forgetting.

There have been numerous studies of the link between fitness and brain health. But none has addressed the issue of a person’s age when they start an exercise regimen.

So, for the first of the new studies, which was published in the Lancet Public Health, researchers at the Norwegian University of Science and Technology in Trondheim, Norway, decided to look into whether by midlife or retirement age, it might be too late to see any improvements.

They began by turning to records from a large-scale health study that had enrolled almost every adult resident in the region around Trondheim beginning in the 1980s in order to track how their health changed over 10 years. The researchers pulled records for more than 30,000 of these participants and categorized them by their fitness.

Some had stayed out of shape; they remained in the lowest 20% of aerobic fitness for the entire 10 years. Others moved into or out of that group. And the fittest few remained outside that group for all 10 years. The researchers then checked records from nursing homes and specialized memory clinics to see which participants developed dementia during a 20-year follow-up period.

They found that the people who were fit throughout the study proved to be almost 50% less likely to develop dementia than the least-fit men and women. Perhaps more encouraging, those men and women who had entered middle age out of shape but then gained fitness showed the same substantial reduction in their subsequent risk for dementia.

The study did not examine what types of exercise were being done by those who gained fitness. Which makes the other new study about exercise and memory a valuable complement.

That experiment, which was published in Applied Physiology, Nutrition, and Metabolism, researchers at McMaster University in Ontario began by recruiting 64 sedentary men and women 60 or older and measuring their fitness and memory skills.

The researchers randomly assigned the volunteers to start exercising. One group walked moderately and steadily on treadmills three times a week for about 50 minutes. The others began interval walking, during which their treadmills’ incline was cranked high for four minutes so that their heart rates rose to about 90% of each person’s maximum.

After 12 weeks, the interval walkers showed significant improvements in both physical endurance and memory performance, and their gains were linked. The more fit someone became, the more his or her memory sharpened.

In essence, the findings suggest that “it is not too late” for middle-aged or older people to start exercising and protect their memories, said Jennifer Heisz, an associate professor at McMaster University who oversaw the new study.

But the exercise needs to be at least somewhat intense, so that it raises heart rates and boosts fitness.

“I tell people to add in some hills when they go for a walk,” she said, “or pick up the pace between streetlamps.”