Pear DB and memory usage

From: Date: Thu, 15 Nov 2007 07:51:48 +0000
Subject: Pear DB and memory usage
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28181@lists.php.net to get a copy of this message
Hi, I wrote a simple script for filling a database table, using pearDB; this script insert 10000 unique record (generate by rand() and limited by unique index on mysql table. My script "eats" memory every time it does a query and it stops for "Allowed memory size" This is script: require_once 'DB.php'; $PEAR_DB_dsn = array(
	          'phptype'  => 'mysql',
	          'username' => 'user',
	          'password' => 'pwd',
	          'hostspec' => '127.0.0.1',
	          'database' => 'database'
	    	);
$db = DB::connect($PEAR_DB_dsn, array('debug'=> 0)); if (PEAR::isError($db)) die($db->getMessage()); } $sth = $db->prepare('Insert into tbprogressivo_sksdo (progressivo) values(?)'); $i = 1; $query_num = 1; echo "<pre>"; while($i < 10000) { $val = rand(10000,99999); $res = $db->execute($sth, array($val)); if (PEAR::isError($res)) {
    		echo "Duplicate value: $val\n";
} else { $i++; } echo 'Query nr. ' . $query_num . "\n"; echo memory_get_usage() . "\n"; $query_num ++; } Memory usage: Query nr. 1 => 702920 ... Query nr. 138 => 1586752 (twice memory usage) ... Finaly: Query nr. 4978 => 33546996 Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 42 bytes) in /usr/share/pear/PEAR.php on line 868 What is wrong? OS: Centos5, PHP 5.2.4 Thanks a lot, Francesco

« previous php.pear.general (#28181) next »