memory usage/release & GC

From: Date: Fri, 31 Dec 2010 05:18:51 +0000
Subject: memory usage/release & GC
Groups: php.general 
Request: Send a blank email to php-general+get-310404@lists.php.net to get a copy of this message
Hi folks, With the recent thread about password & security, I wrote a small quick script to generate a random or all possible passwords based on certain parameters for a brute force use. On a very long running execution for a complex password in length with full use of the keys (94 characters), including upper case, the script seems to consumes more memory (shown in Windows task manager) as time progress. Below are snippets from the script file that does the workload: while (!$this->isMax()) { for ($b = 0; $b <= $this->pwdLength; $b++) { if ($this->counter[$b] < $this->max) { $this->pwd[$b] = $this->charList[$this->counter[$b]]; $this->counter[$b]++; break; } else { $this->counter[$b] = 1; $this->pwd[$b] = $this->charList[0]; } } } private function isMax() { for ($a = $this->pwdLength-1; $a>=0; $a--) { if ($this->counter[$a] < $this->max) return false; } return true; } Could someone please tell me why the above code consumes additional memory as time progress for the execution of the while loop? Researching PHP GC on google didn't shed light on problem. Generating all possible combinations for 20 length with 94 possibilities each, the script easily consumes more than 1GB RAM in few minutes. BTW, gc_enabled() reports on. Thanks, Tommy

« previous php.general (#310404) next »