PHP Memory Management

From: Date: Sat, 02 Aug 2008 20:38:06 +0000
Subject: PHP Memory Management
Groups: php.general 
Request: Send a blank email to php-general+get-277637@lists.php.net to get a copy of this message
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

« previous php.general (#277637) next »