Our brains file memories during rest
A UCLA study of rats (which are very similar to human in terms of brains) found that memories formed in one part of the brain are replayed and transferred to a different area during rest.
http://www.medicalnewstoday.com/releases/309296.php