Chest contents are saved whenever you change them (game saves, changing contents, chunk updates). Your inventory only saves when you log out. So if you acquire something you want to keep, either stash it in a chest or log out and back in to force a save of your player.dat file.2) How should I avoid this in the future? Does logging out save it?
--Patrick