We all pull an all-nighter once in a while. It could be for a fun reason, like a sleepover or an adventurous night. Other times, it's for something less fun like writing a paper or studying for an exam.

In university, pulling an all-nighter for various reasons is quite common. But what does it really do to your body, physically and mentally? Here's what an all-nighter does to your body, according to science.

Your Memory

Staying up all night to cram for an exam? Turns out, this is counter-productive. According to science, you'll have trouble remembering anything you tried to learn the day before.

When you sleep, part of your brain replays what you've learned while you're awake and encodes it to your long-term memory. If you don't sleep, this process doesn't take place, and there'll be no long-term memory of those lessons.

Your Circadian Rhythm

Every cell in your body contains its own circadian clock and your hypothalamus keeps them all running in sync. For example, it activates the appropriate release of hormones for the time of day, dictating your eating and sleeping cycles. If you stay up all night, your signalling gets completely out of whack. This can lead to a whole slew of symptoms including nausea, fatigue, and sleepiness.

Your Brain

Your brain just doesn't work as well the longer you've been awake. It becomes less efficient at burning energy due to something called ATP molecules, which help the brain burn fuel. They're replenished while you sleep, so if you pull an all-nighter, your brain's efficiency will go way down.

Your Judgment

When your brain becomes less efficient at burning energy, that impacts your prefrontal cortex—the part of the brain responsible for good judgment and decisions. When it stops working well, guess what happens? You start to make bad decisions. That's why people say driving tired is the same as driving drunk.

Your Stomach

Besides the nausea, messing up your circadian rhythms can also increase your appetite. The two hormones in your body that regulate appetite—leptin and ghrelin—are produced in an unbalanced quantity, making you hungrier.

Your Immune System

Sleep deprivation suppresses the immune system and impairs our fever response. Not only will it be easier for you to get sick, but it'll take a lot longer to recover as well.

Long-Term Effects

While you can recover from one sleepless night with a subsequent full night of sleep, the long-term effects of repeated sleep deprivation are pretty scary.

High blood pressure, heart attack, heart failure, cancer, stroke, obesity, psychiatric problems, mental impairment, injury from accidents and poor quality of life are just a few possibilities. Studies have even shown an increased mortality risk for those reporting less than six or seven hours per night.

The Takeaway

While an all-nighter every once in a while isn't going to do much damage (besides making you feel like garbage the next day), consistently getting fewer than 6 hours of sleep can have some dangerous long-term effects.

For adults, the aim is to get 7-8 hours of sleep per night. Write that essay during the day and get some decent shut eye—your body will thank you.