I've been running the script below:

<?php
  $appIds = getLotsOfAppIds();
  foreach ($appIds as $appId) {
    echo "$appId\n";
    //echo memory_get_usage() . "\n";
    try {
      $getBundles = getBundles($appId);
      $numBundles = count($registeredBundles);
      echo $numBundles . "\n";
      continue;
    }
  }
?>

And I get PHP Fatal Error: Allowed Memory Size Exhausted after it runs for a
bit.  Looking at the memory usage, it's because $getBundles (an array) is
huge, and keeps growing.  What I'm confused by is why setting it to
something else in the next iteration of the foreach loop doesn't free the
previously allocated array, since there shouldn't be any more references to
it.  I've worked around it by explicitly calling unset($getBundles), but
just wanted to understand why it's working the way it does.

Thanks,
Waynn

Reply via email to