In general, this happens to me while trying to fall asleep. Very random, distinct, sharp and lucid childhood memories of certain points in time, though I do have be drifting into sleep. I've certainly never had it when trying to actively memorize new material.