Portable app keeps running after RAM disk is formatted
3 posts
I placed a portable app entirely contained in its folder in a RAM disk and ran it. While it was running, I formatted the RAM disk, a process that deleted its contents as expected, yet the app continued running. Obviously, this cannot be magic, so simply out of curiosity, could I ask for a technical explanation that a layperson can understand?
When Windows runs a program, it doesn't simply fully load the file into memory and hold onto it. It maps the file, then copies bits of it into RAM when they are actually needed. If your app is small, within a second or two everything it needed was already sitting in RAM. The file on disk had become irrelevant.
A format doesn't erase data - it just writes a fresh, empty index. The old bytes are still there, just unlisted. A real-life parallel with a library would be: you burned the library card catalogue, not the books.
So the app kept running from the copy already in memory. It got lucky in your particular case, though: if it had later needed a chunk of code it hadn't touched yet, it would have gone looking for a file that no longer had a home and crashed instantly. And anything it tried to save would have failed too.