I do believe that you remember what you studied right before you go to sleep. I have had it happen before where I am studying for a test and I am dreaming about what I studied or if I am half awake I am repeating questions to myself. I think its weird but awesome in another way because I know that I learned it. The book also talks about being sleep deprived that it does not help with memory. I read on several websites that tests were administered on people who were sleep deprived did worse on memory or recognition tests than people who slept. I think it’s harder for someone to remember or even concentrate on something when you are tired. I know when I am tired and studying or doing something I can’t think right. I am too focused on being tired and going to sleep than doing what needs to get done. I also read that not even caffeine helps with sleep deprivation and memory. So that means that staying up late studying and drinking lots of coffee is going to help you remember. Maybe it might keep you up but if you are deprived of sleep its probably not going to help your memory.
I also read that you need sleep to consolidate your memories. Sleep is critical to convert new memories into long term memories. A study showed that brain regions shift dramatically during sleep. So in other words the researcher says, you are shifting your memory to a more efficient storage regions within your brain. So, study before you go to bed. Don't stay up all night studying because it is not going to help you.