There are multiple levels of memory, some of which would die immediately, some of which would take some time. So the answer is: it depends; some immediately, some only very slowly.
At the highest level, the current neuronal firing state of the brain encodes memory on a very short scale - working memory. The memory held on this level does not have a clear anatomical counterpart (but for the potential encoded in the synapses). It equals very short-term memory/STM sequences, such as the words you read just before you read the words you're reading right now. This memory is lost immediately when you lose consciousness, at least to some degree; as this memory is hard to even strictly distinguish from consciousness and attention (though see Jonides et al. 2008).
Other forms of short-term memory/STM are stored in a slightly different form: short-term potentation, the adaption of neuronal responses following brief and intense stimulation. Spike Frequency Adaption/SFA is at an intermediate stage between this and the previous level. Short-term potentation and SFA decay within minutes or even seconds if they are not transferred into some more durable form of memory.
Long-term memory (/LTM) stores have specific anatomical correlates; they are stored in, amongst others, the synaptic weights (i.e. the amount of influence the firing of one neuron has on another). Some forms of LTM are best located in cortical synapses, others in the hippocampus. An even more fundamental, long-term, durable storage form is the wiring itself; not just the weights, but the existence of a synapse between two points, or not. For example, an important part of early learning is synaptic pruning, where synapses which do not play a meaningful role die off, whereas those which connect functionally related brain areas remain.
This pruning instantiates one form of learning, and the non-existence of a synapse is a form of memory. Synapses are comparatively stable. Even if the corresponding neurons die, in principle, the synapses still exist - and more importantly, the nonexistence of a synapse is even more durable. This form of memory can be observed in slice preparations of animals long dead.
For a simple example, consider any experiment on the neuronal responses in slice preparations, which can be considered a form of (decontextualised) memory access.
On the most extreme end, epigenetic adaptions and large-scale brain anatomy (which shows developmental traces) can be considered a form of memory that will remain intact until the whole structure rots away.
However, the more direct answer to the question the OP is asking is that once a large amount of neurons have died (brain death), there is currently no power on earth that can access a non-trivial amount of memory. As long as this is averted, nontrivial amounts of memory can be recovered.
For the parts that are lost immediately, see the source by Jonides et al. For more durable memory, you could look at for example Purves et al, Neuroscience.