Rudy Lippan [[EMAIL PROTECTED]] wrote:
> On Thu, 20 Dec 2001, Hardy Merrill wrote:
>
> > > A new hash is returned but the old one should get GC'd right? You
> > > are assigning a new hash to $row and, assuming that, there are no other
> > > referances to the old hash it should just go away when $row gets a new
> > > ref, or am I missing something?
> >
> > I'm curious about this now - it would seem that Rudy is right,
> > that when the hashref scalar gets assigned the reference to the
> > "new" hash, then the only existing reference to the old hash
> > should disappear, which should in theory(?) make the memory
> > taken by that old hash available again via garbage collection,
> > right? Why isn't this happening?
>
> I did not get a chance to play with this, but I am guessing that he is
> using a dbd that sucks down all of the records on execute and only returns
> them to the script when calling fetch* methods. For these DBs there is
> not much of a difference in doing the loop method vs. the fetchall*
> method. Postgres, for one, behaves like this, though you can get around
> this by using cursors || by selecting subsets.
I looked back at Groetjes's message where he described the
memory problem:
while( $hash_ref = $query->fetchrow_hashref ) { ... }
It didn't matter if the while contained something or
nothing... the memory usage kept growing with each row
it fetched. He had to fetch about 300.000 rows ... It
began at 5MB and quit at +/- 80MB.
Rudy, if you're right that DBD::mysql(Groetjes said he was
using MySQL - he still didn't name DBD::mysql yet, but I'm
assuming) sucks down all the records on execute, then
I would expect that he would see his memory jump up once -
not for each and every fetchrow_hashref like he is describing.
Am I missing something?
Since his memory usage keeps growing with each fetchrow_hashref,
it would seem that the problem may be with fetchrow_hashref
in general, or ??? We use DBD::Oracle, but I'm not in a
position to test this to see if each fetchrow_hashref eats
more memory.
Can anyone shed some light on what's going on here - is it an
issue with DBD::mysql, or the DBI fetchrow_hashref in general,
or what?
TIA.
--
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com