In a Ted-Ed lesson written by educator Elizabeth Cox, narrator Christina Greer explains how memory is connected to stress levels through corticoidsteroids. Corticosteroids affect the hippocampus, which is where memories are cemented and the frontal cortex, where memories are recalled. In the case of extreme stress such as the fight, flight or freeze response, however, this state of flooding corticosteroids can temporarily wipe out any recall available while dealing with clear and present danger.
When corticosteroids stimulate the amygdala, the amygdala inhibits, or lessens the activity of, the prefrontal cortex. The reason for this inhibition is so the fight/flight/freeze response can overrule slower, more reasoned thought in a dangerous situation. But that can also have the unfortunate effect of making your mind go blank during a test. And then the act of trying to remember can itself be a stressor, leading to a vicious cycle of more corticosteroid release.