Computer codes - how long stored?

I see lots of discussion about reading codes and how to erase them, but what about the other side of that question. Once a code is stored in the computer, how long does it stay there? Forever? Even if power is removed? Only through a certain number of engine starts and stops? A certain length of time?

I’m talking here about a situation where the check engine light has come on and then gone out on its own. I assume that, if the light comes on and stays on, the code will of course be there.

Thank you.

I believe the codes remain stored as long as power is applied or until someone intentionally clears them with a scan tool. Even “temporary” problems that cure themselves will leave a record until they are cleared…Disconnecting the battery will clear the codes…

Thank you.

UR Welcome…

Yes. They’re stored forever. With the proper scanner you can look up the history codes.