title: Why does the memory allocated get halved when loading a resource for every following request?
body: <p>While debugging memory allocation, I noticed that the memory usage is halved for every following request.</p>
  
  <p>The script looks like this:</p>
  
  <pre><code>&lt;?php
  
  ini_set('memory_limit', '256M');
  
  var_dump(memory_get_usage());
  
  $im = imagecreatefromjpeg('image.jpg');
  
  
  var_dump(memory_get_usage(true));
  
  imagedestroy($im);
  </code></pre>
  
  <p>First request:</p>
  
  <pre><code>/Users/john/code/testing/index.php:5:int 401192
  /Users/john/code/testing/index.php:10:int 218103808
  </code></pre>
  
  <p>Second request:</p>
  
  <pre><code>/Users/john/code/testing/index.php:5:int 401160
  /Users/john/code/testing/index.php:10:int 216006656
  </code></pre>
  
  <p>Third request:</p>
  
  <pre><code>/Users/john/code/testing/index.php:5:int 401160
  /Users/john/code/testing/index.php:10:int 109051904
  </code></pre>
  
  <p>Fourth request:</p>
  
  <pre><code>/Users/john/code/testing/index.php:5:int 401160
  /Users/john/code/testing/index.php:10:int 54525952
  </code></pre>
  
  <p>The script is run on PHP 7.1 using the built in web server. (<code>php -S localhost:8000</code>)</p>
  
  <p>What's happening here?</p>