Sleep is integral to memory. When you are sleeping, your brain gets a chance to forget about the outside world for a bit and just concentrate on itself. During this time it can enhance connections between different parts of the brain and produce structural changes that become our memories, a process known as consolidation. This plasticity, the ability to change in relation to previous experience, is what makes the brain such a great machine.