Living people have physical brains, and those brains contain loci that when electrically stimulated call forth detailed memories. When a person dies, the brain dies with him or her, so spirits have no physical way of recalling a past memory. The memory that any given spirit is able to recall depends on its state of evolution.
Each spirit that remains on the transitional plane may have a limited range of memories. Some have a much larger repertoire over a much longer span of time. Some re-experience a slice of memories from much earlier in their lives. Others have nearly no real memories at all and seem more like a bundle of desires and urges than whole personalities.
Ghosts are spirits trapped on the timeless transitional plane. It appears that the longer that they remain on the transitional plane, the smaller their reservoir of memory becomes. Hans Holzer, who has spent decades investigating ghosts, believes that all ghosts are psychotic. This is probably because most of the ghosts he has studied have spent hundreds of years haunting old buildings and have forgotten most of the elements of their lives, including their own names. I believe that this phenomenon is similar to living people who are kept in sensory isolation for long periods of time and who develop serious personality defects as a result.
However, once a spirit has decided to cross over from the transitional plane into the mainstream sequence, the memory of its past life, along with a full sense of continuity is restored. In the mainstream spiritual world, all the memories that a person has accumulated over his or her lifetime are permanently accessible after death.
Where spiritual memories are stored is unknown, although some believe that all memories and events are stored in what has become known as the Akashic records. They are said to contain a record of ALL events, thoughts and actions, past, present and future. It appears that any given spirit can access only those records that pertain directly to it. I can’t argue for the reality of these records, but spiritual memories have to exist somewhere, and the Akashic records are a reasonable explanation for how spirits may be able to draw on the forgotten memories of their own lives.