I’ve recommend the book Spark by John Raty elsewhere on this forum and I’ll do so again here. It’s a fantastic book length treatment of this very complex topic.
In general, a “minimal effective dose” would vary greatly according to each person’s mental, physical, and emotional circumstances–it’s all connected in surprising ways. More generically, the daily recommendation for general physical and mental health is weekly aerobic activity minutes burning calories equal to eight times your body weight. So, based on typical body weight/heart rate/calorie metrics, if you weight 150 lbs, that is six 200 calorie 30 minute sessions.
This is the minimum recommended. This is less than half of the amount of energy usage that our genes are encoded for. Paleolitic ancestors would need to walk 5-10 miles each day just to gather enough food to eat.
Keep in mind also that mental health broadly and memory specifically is influenced by factors such as nutrition and social relationships as well. If you get the “minimum effective dose” of exercise and eat poorly and are unhappy, lonely, and depressed, you’re still cognitively well below peak performance.
On the exercise only aspect, the best, research, based on when that book was written in 2008, however, would be to do some form of aerobic activity six days a week, for forty-five minutes to an hour. Four of those days should be on the longer side, at moderate intensity, and two on the shorter side, at high intensity.
If you google around for Brain-Derived Neurotrophic Factor or BDNF, you’ll find the research on how BDNF is like “miracle-gro” for the brain, if you’re interested in specific neurological benefits.
Based on current research, there doesn’t seem to be a clear upper limit of where exercise becomes wasted effort. From a practical point of view, it’s more about time management and less about optimal exercise. There are only 1440 minutes in each day, and it’s up to you to decide how you’d like to spend them!