You know the feeling. You stayed up all night, the exam or the deadline or the night shift is finally behind you, and your brain feels like wet cardboard. A new study out of McGill University has some oddly good news for mornings exactly like that: if real sleep is off the table, twenty minutes of hard cycling or a ninety-minute nap can each protect your memory almost as well as the other, and when it came to memory after sleep loss the two fixes worked about the same.

The McGill-led team kept 54 healthy adults between the ages of 18 and 35 awake for 30 straight hours under lab supervision. Then they split them into three groups. One group rode a stationary bike at a moderate-to-vigorous pace for twenty minutes. Another got a ninety-minute nap. The third group, the control, simply sat on a stationary bike for twenty minutes without pedaling.

Right after the interventions, everyone viewed 150 images while researchers recorded their brain activity with electroencephalography, or EEG. Nobody was told a memory test was coming. Three days later, after everyone had time to recover, the researchers showed the same images mixed with new ones and asked which they remembered. According to the team, the people who had exercised or napped remembered about 22 percent more images than the people who did neither. The results were published in the journal Proceedings of the National Academy of Sciences.

Testing memory after several days was deliberate. It let the researchers check whether the interventions shaped the formation of lasting memories, rather than just delivering a brief jolt of alertness. The takeaway matters for anyone whose schedule runs on exhaustion: shift workers, students deep in finals season, new parents, anyone grinding through long hours who cannot simply stop and sleep.

Same score, different rescue routes

The most interesting part is that the nap and the workout arrived at the same result through different doors. Brain recordings showed the two interventions leaning on separate neural pathways. Napping appeared to help the brain recharge, making it easier to take in and hold on to new information. Exercise, by contrast, helped the brain use its remaining resources more efficiently, and it did so without making participants feel more tired.

"Sleep loss affects nearly every aspect of how we think and function, but many people can't simply stop what they're doing and get more sleep," said senior author Marc Roig, a professor in McGill's School of Physical and Occupational Therapy. "Our findings show that even a brief bout of exercise may help preserve one of our most important cognitive abilities."

The team framed the work around practical fatigue management. McGill's newsroom noted that the research could inform strategies for people who work long hours, where a full night of sleep is not always on the menu. The brain, the researchers suggest, is more flexible than it looks: even under severe sleep deprivation it recruited different neural pathways to keep memory intact.

What to do with this at 6 a.m.

None of this is a permission slip to stop sleeping. The study was small, the deprivation was extreme, and thirty hours without sleep is far past an ordinary late night. What the findings offer is a hierarchy for the worst mornings. If you can nap for ninety minutes, do it. If you cannot spare ninety minutes, a brisk twenty-minute ride at a pace that gets your heart working counts. The study's cycling group went at about 80 percent of maximum heart rate, which is the kind of effort where holding a conversation gets difficult but stays doable.

There is a small catch worth knowing. The exercise has to be actual exercise. The control group sat on the same bikes for the same twenty minutes without pedaling and saw no benefit. Motion alone was not the trick; effort was.

CNN's wellness coverage of the study, reported by emergency physician and George Washington University professor Dr. Leana Wen, walked readers through the design and its limits: the sample was small, everyone was healthy and young, and nobody has yet tested whether the same tricks work after ordinary short nights rather than a full thirty hours awake. Still, for a generation that runs on caffeine and crossed fingers, the message on memory after sleep loss is refreshingly concrete. When sleep is not an option, a nap is gold and a short hard workout is silver, and doing nothing was the only approach that failed to help.

Related: 11 minutes extra sleep daily slashes heart disease risk; just minutes of vigorous exercise daily slashes disease risk.

Source: McGill University newsroom; CNN health