What precisely does 'PlayerPrefs.Save' do?

The documentation page isn’t exactly helpful explaining what it does.

If I have several pref values, say what ID item the player has in their inventory slots, I could just do;

    PlayerPrefs.SetInt("item1", 3);
    PlayerPrefs.SetInt("item2", 5);
    PlayerPrefs.SetInt("item3", 4);

at a save point. what does PlayerPrefs.Save do any different?

When you write

PlayerPrefs.SetInt("item1", 3);

It doesn’t get saved on disk yet, it’s still in RAM. It will only be saved to disk when you quit the application normally (for example, calling Application.Quit()).

So if after you call SetInt, the game crashes, or you use “force quit” on it, the next time you opened the app, it may not remember what you told it to save.

If you write PlayerPrefs.Save(), it will write to disk all the things you previously set with SetInt or similar, so you don’t have to wait until you quit the game.

So why doesn’t it just write to disk whenever you call SetInt? Well, writing to disk is a time-consuming operation. If you call it a lot during the game, it may reduce your framerate or slow down the whole game, so it’s best that you control when it happens (for example, only during menus or other times that are less resource-intensive).