Remember to eat your fruits and veggies: They might just boost your memory.

Scientists have linked several kinds of produce — including leafy greens, orange and red vegetables, berries and orange juice — to better memory.

Researchers at Harvard University have found that men who consistently ate those fruits and vegetables over a period of 20 years were more likely to have better memory skills than their produce eschewing counterparts, according to a study published in the journal Neurology.

The study followed about 27,800 men in health-care jobs over a span of 20 years, and surveyed them on their diet and other health-related topics every four years.

Toward the end of the study, the researchers started asking them questions about their memory: For example, “Do you have more trouble than usual remembering a short list of items, such as a shopping list?” or “Do you have more trouble than usual following a group conversation or a plot in a TV program due to your memory?”

A growing number of “yes” answers to such questions can signal cognitive decline, the researchers say.

The participants were sorted into five groups, based on how many servings of vegetables and fruits they got per day, from six servings in the healthiest group to just two servings at the other end of the spectrum.

The six-serving eaters were 34 percent less likely to be forgetful. And the results were even better if the men happened to steer toward carotenoid-rich vegetables, such as carrots, pumpkin and spinach.

Furthermore, those who drank orange juice often were 47 percent less likely to become forgetful, compared with those who drank OJ less than once a month.

“Our studies provide further evidence dietary choices can be important to maintain your brain health,” researchers say.