Re: DB_DataObject eats all my memory

From: Date: Tue, 26 Oct 2004 15:38:49 +0000
Subject: Re: DB_DataObject eats all my memory
References: 1  Groups: php.pear.general php.pear.general 
Request: Send a blank email to pear-general+get-15122@lists.php.net to get a copy of this message
There's an example in CVS http://cvs.php.net/co.php/pear/DB_DataObject/tests/memoryTest.php?r=1.2 this shows how to do queries without killing memory. - It's not expected that DataObjects would work well in a complex situation huge data sorting results. That said, I have used it in a number of huge data conversion situations, without killing memory. basically if you run ->free() - dont expect any 'open' dataobject to behave nicely.. - it has to do a wipe of the numrows cache in a DB:: global. - (nasty hack) - this may be fixable in a better way, but I've not had time to look at it. Regards Alan Sven Lankes wrote:
I have a script where I'm doing a lot of sql queries. This script eats memory until it's killed by the OOM-Killer at some point (using much more than 1GB). DB_DataObjects seems to be at fault. I have created a very simple testcase:
for ($i = 1; $i < 50000; $i++) {
      $test = new DataObjects_Test;
      $test->whereAdd("field2 like '4%'");
      $test->find();
      while ($test->fetch()) {
      }
}
The Test-Table consists of 100000 lines of random noise. If I run above code it starts out with a ps aux output of:
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
sven     15451 41.0  1.4 94612 15308 pts/7   S+   00:09   0:00 php ./read.php
after a couple of hours it looks like this:
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
sven     15451 73.4  7.4 155560 76160 pts/7  S+   00:09 382:40 php ./read.php
Rewriting my test-script using only the php postgres commands I can run it for hours w/o an increase in memory consumption. Any hints on how to solve this would be appreaciated. I'm using php 4.3.9, postgres 7.4.5 and DB_DataObject 1.7.2


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