More people are living longer these days, but the good news comes shadowed by the possible increase in cases of age-related mental decline. By some estimates, the global incidence of dementia will more than triple in the next 35 years. That grim prospect is what makes a study published in March in The Journal of Alzheimer’s Disease so encouraging: It turns out that regular walking, cycling, swimming, dancing and even gardening may substantially reduce the risk of Alzheimer’s.

Exercise has long been linked to better mental capacity in older people. Little research, however, has tracked individuals over years, while also including actual brain scans. So for the new study, researchers at the University of California, Los Angeles, and other institutions analyzed data produced by the Cardiovascular Health Study, begun in 1989, which has evaluated almost 6,000 older men and women. The subjects complete medical and cognitive tests, fill out questionnaires about their lives and physical activities and receive M.R.I. scans of their brains. Looking at 10 years of data from nearly 900 participants who were at least 65 upon entering the study, the researchers first determined who was cognitively impaired, based on their cognitive assessments. Next they estimated the number of calories burned through weekly exercise, based on the participants’ questionnaires.

The scans showed that the top quartile of active individuals proved to have substantially more gray matter, compared with their peers, in those parts of the brain related to memory and higher-­level thinking. More gray matter, which consists mostly of neurons, is generally equated with greater brain health. At the same time, those whose physical activity increased over a five-year period — though these cases were few — showed notable increases in gray-matter volume in those same parts of their brains. And, perhaps most meaningful, people who had more gray matter correlated with physical activity also had 50 percent less risk five years later of having experienced memory decline or of having developed Alzheimer’s.

“For the purposes of brain health, it looks like it’s a very good idea to stay as physically active as possible,” says Cyrus Raji, a senior radiology resident at U.C.L.A., who led the study. He points out that “physical activity” is an elastic term in this study: It includes walking, jogging and moderate cycling as well as gardening, ballroom dancing and other calorie-burning recreational pursuits. Dr. Raji said he hopes that further research might show whether this caloric expenditure is remodeling the brain, perhaps by reducing inflammation or vascular diseases.

The ideal amount and type of activity for staving off memory loss is unknown, he says, although even the most avid exercisers in this group were generally cycling or dancing only a few times a week. Still, the takeaway is that physical activity might change aging’s arc. “If we want to live a long time but also keep our memories, our basic selves, intact, keep moving,” Dr. Raji says.