title: Is it less computer intensive to load and unload an image every time a new image is needed or to have all of the images loaded at once? (SDL)
body: <p>I've created a small animation for a game that uses a set of images as frames, and the current image to render changes over a certain amount of time to create the animation illusion. I've done this in two different ways, and I'm wondering which one is more efficient to use.</p>
  
  <p><strong>Method 1:</strong>
  A single image is loaded and rendered. When a different image needs to be rendered, a function is called that unloads the current image, and loads and renders the new one.</p>
  
  <p><strong>Method 2:</strong>
  All of the images needed for the animation are loaded once, and then rendered as needed.</p>
  
  <p><strong><em>In simpler terms:</em></strong> Method 1 unloads the current image and loads the new one every time a different image is needed, and Method 2 keeps all the images needed loaded at once.</p>
  
  <p>So basically, the question is, it better to constantly load and unload images to keep as little loaded as possible, or to have many loaded at all times and not unload/load anything during the program? <strong>Does the computer have a harder time loading and unloading images or keeping many images loaded at once?</strong></p>
  
  <p>I ran looked at the task manager while running each method. CPU usage of Method 1 (loading and unloading) fluctuated between 29% and 30%, while that of Method 2 fluctuated between 28% and 29%.</p>
  
  <p>It appears that keeping all the images loaded is better according to these statistics, but the reason I don't really trust them is because the program only loads seven images. </p>
  
  <p>As the game gets bigger, there could be <strong>hundreds of images loaded at once</strong> (Method 2) or <strong>an image loaded and unloaded nearly every frame</strong> (Method 1). Which method is less intensive? Thank you for your time.</p>