Ever walk into another room and completely forget why you're there? You're not alone and you're (probably) not going insane — you're just a victim of what's called the Doorway Effect.
Researchers from the University of Notre Dame set up an experiment to see just how walking from one room to another in a controlled environment actually impacted memory. The tests were done both in a virtual setting, and a real life one. Participants were asked to walk into a room and pick up an item. In the game, it disappeared into a virtual backpack while in real life, it was hidden in a box. They would then walk into a different room, put the object down, pick up another one, rinse, and repeat.
At various points in the exercise, they stopped and asked people what was in their box (or inventory). If they were asked right after going through a door, they were less likely to remember and slower to respond whether they were in a real environment or a virtual one. So what's going on? They called it the "event model," which basically means our memories work great until our brain decides the information it's holding onto isn't useful any more.
Another way to think about it is that it's bad timing, and whatever you've forgotten is the bit that your brain has decided is the least useful. If you're thinking about, say, picking up dog food, worrying about a presentation you've got at work tomorrow, wondering what you're going to make for dinner, and going to the kitchen for a cup of coffee, your brain is likely to shove that cup of joe right off your radar. When you change your physical environment at the same time, your mental one is changing gears, and sometimes those gears slip. You drop things. But don't worry, it wasn't important.