The need for sleep goes far beyond simply replenishing our energy levels every 12 hours. Our brains actually change states when we sleep to clear away the toxic byproducts of neural activity left behind during the day.

Weirdly enough, the same process starts to occur in brains that are chronically sleep-deprived too - except it's kicked into hyperdrive.

Researchers have found that persistently poor sleep causes the brain to clear a significant amount of neurons and synaptic connections, and recovering sleep might not be able to reverse the damage.

A team led by neuroscientist Michele Bellesi from the Marche Polytechnic University in Italy examined the mammalian brain's response to poor sleeping habits, and found a bizarre similarity between the well-rested and sleepless mice.

Like the cells elsewhere in your body, the neurons in your brain are being constantly refreshed by two different types of glial cell - support cells that are often called the glue of the nervous system.

The microglial cells are responsible for clearing out old and worn out cells via a process called phagocytosis - meaning "to devour" in Greek.

The astrocytes' job is to prune unnecessary synapses (connections) in the brain to refresh and reshape its wiring.

We've known that this process occurs when we sleep to clear away the neurological wear and tear of the day, but now it appears that the same thing happens when we start to lose sleep.

But rather than being a good thing, the brain goes overboard with the clearing, and starts to harm itself instead.

Think of it like the garbage being cleared out while you're asleep, versus someone coming into your house after several sleepless nights and indiscriminately tossing out your television, fridge, and family dog.

"We show for the first time that portions of synapses are literally eaten by astrocytes because of sleep loss," Bellesi told Andy Coghlan at New Scientist.

To figure this out, the researchers imaged the brains of four groups of mice:

one group was left to sleep for 6 to 8 hours (well-rested)

another was periodically woken up from sleep (spontaneously awake)

a third group was kept awake for an extra 8 hours (sleep-deprived)

and a final group was kept awake for five days straight (chronically sleep-deprived).

When the researchers compared the activity of the astrocytes across the four groups, they identified it in 5.7 percent of the synapses in the well-rested mouse brains, and 7.3 of the spontaneously awake mouse brains.

In the sleep-deprived and chronically sleep-deprived mice, they noticed something different: the astrocytes had increased their activity to actually eating parts of the synapses like microglial cells eat waste - a process known as astrocytic phagocytosis.

In the sleep-deprived mouse brains, the astrocytes were found to be active across 8.4 percent of the synapses, and in the chronically sleep-deprived mice, a whopping 13.5 percent of their synapses showed astrocyte activity.

As Bellesi told New Scientist, most of the synapses that were getting eaten in the two groups of sleep-deprived mice were the largest ones, which tend to be the oldest and most heavily used - "like old pieces of furniture" - which is probably a good thing.

But when the team checked the activity of the microglial cells across the four groups, they found that it had also ramped up in the chronically sleep-deprived group.

And that's a worry, because unbridled microglial activity has been linked to brain diseases like Alzheimer's and other forms of neurodegeneration.

"We find that astrocytic phagocytosis, mainly of presynaptic elements in large synapses, occurs after both acute and chronic sleep loss, but not after spontaneous wake, suggesting that it may promote the housekeeping and recycling of worn components of heavily used, strong synapses," the researchers report.

"By contrast, only chronic sleep loss activates microglia cells and promotes their phagocytic activity ... suggesting that extended sleep disruption may prime microglia and perhaps predispose the brain to other forms of insult."

Many questions remain, such as if this process is replicated in human brains, and if catching up on sleep can reverse the damage.

But the fact that Alzheimer's deaths have increased by an incredible 50 percent since 1999, together with the struggle that many of us have in getting a good night's sleep, means this is something we need to get to the bottom of - and fast.

The research has been published in the Journal of Neuroscience.

An earlier version of the story was published in May 2017.