Loading all images at once, or as-needed

So, I’ve been wondering what method of loading assets would be better:

  1. Load all assets at once when the game is first run. This will mean that all the assets will be kept in memory. Sounds, music, images for in-game, images for menus, everything.

  2. Load everything as needed. At the start of each menu, only it’s needed images will be loaded. When the game starts, it will release the menu assets from memory and load the assets for game play.

Currently, I’m using method 1, but I feel like I should switch to method 2 to conserve memory. What do you think, and what method do you use?

I would say go with method 2, as it will take up far less memory, which is obviously a good thing. If your game is small (pong clone, pac man, whatever else), and you don’t have a ton of assets, then no it wouldn’t be a huge deal. But think about it, say you have a image that will only be used for the menu, why keep it in memory if you don’t need it?

Exactly what I was thinking. My game is slowly getting bigger and bigger, and it occurred to me that method 1 (which I had used for smaller games) would not be a good idea for a more advanced game.
Loading a 1mb background picture for the menu and keeping it in the memory during gameplay when it isn’t needed seems like a bad idea.

I would also recommend using spritesheets to store all your textures instead of loading them individually, it’ll reduce your memory footprint if your images aren’t huge.

Yeah, method 2 is definitely the way to go; However, you’ll want to multithread asset loading, otherwise performance will tank in short bursts every time something new happens, which you definitely don’t want.