title: php allocates huge amount of memory for echo
body: <p>I have code which uses gmagick to render images. It runs on Php5.6 Ubuntu 16.06 machines (Apache2).</p>
  
  <p>The code echoes the raw data of the image and together with png header so it shows the images.</p>
  
  <p>I've set the same config on a new server. On the new server the same code works for random images but for a single specific image it fails when the image raw data produced by gmagick is echoed because php tries to allocate huge space for the string echo. (tried to allocate 1864914417 bytes).  The string it needs to echo is 250Kb. </p>
  
  <p>It looks like for a particular image it mistakes the 250K string to be much larger and tries to allocate a huge buffer.</p>
  
  <p>The only difference between the servers is that the old one is php5.6.37 and new one is php5.6.40.</p>
  
  <p>What can cause this ?</p>
  
  <p>BTW Output buffering is On on both the old and new servers.
  The phpinfo of both is the same.</p>