What happens if PlayerPrefs.Save() fails?

I/O operations often fail for various reasons, for example, if there’s not enough disk space to write player prefs to file. So if PlayerPrefs.Save() gets the IOException, will it be re-thrown, silenced, or will unity crash? I’d really like to tell the player that they run out of space instead of just crashing (and loosing all their progress).

I didn’t find any specific solution of doing this in the internet. However, I thought about one by myself. It is a bit silly, but if you will not find another way:


  1. After saving data, you just can immediately load them back. If the key exists and the value is the same as you just saved, then everything is okay. Yeah, really you shouldn’t do that often, better never. It will use some extra resources. But if you really need, and there is no other option… You choose…

  2. I believe you can use something from SystemInfo to watch after available memory.

  3. I believe all platforms notify about ending memory automatically. Moreover, they do that far before actual limit. When the user will get a notification from the system about memory exceeding, there still be some place for your data.


As I said, I’ve never used those things. You should be careful, because some memory leaks might be produced. PlayerPrefs saves light data. Therefore, there usually will be some more available place to save it. Otherwise, the platform will be just yelling on the user about this issue automatically. I would rely on this.