Re: Doctrine madness!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 16, 2011 at 1:58 PM, Eric Butera <eric.butera@xxxxxxxxx> wrote:

> On Thu, Jun 16, 2011 at 12:51 PM, Nathan Nobbe <quickshiftin@xxxxxxxxx>
> wrote:
> > Hi gang,
> >
> > If anyone out there has some experience w/ Doctrine now would be a great
> > time to share it!
> >
> > So I'm writing a batch importer and noticed memory usage climbing during
> > script execution.
> >
> > In the debugging effort I've isolated it down to a Doctrine issue.
> >
> > Here's what's going on, I instantiate a model object for the product
> table
> > from my application
> >
> > $newRecord = new Product();
> >
> > at this point memory usage goes up noticeably.  I don't really care
> though
> > because I figure I can delete it, but look at this madness I have going
> > (which *fails* to free up the memory)
> >
> > $newRecord->clearRelated();
> > $newRecord->free();
> > unset($newRecord);
> > gc_collect_cycles();
> >
> > after all of this memory consumption is still dramatically higher than
> prior
> > to the first call creating the object above.  This I've verified through
> > memory_get_usage().
> >
> > here's the output from the memory_get_usage() calls
> >
> > int(166461440) // before new Product()
> > int(169345024) // directly after new Product()
> > int(169345024) // after madness trying to free memory used by new
> Product()
> >
> > I've also tried an explicit call to the destructor of $newRecord, but
> that
> > results in a fatal attempting to call an unknown method.
> >
> > Any help would be greatly appreciated as google hasn't been able to point
> me
> > to the answer thus far.
> >
> > thx,
> >
> > -nathan
> >
>
> This might help
>
> http://php.net/manual/en/features.gc.collecting-cycles.php



Thanks for the reply Eric.

Sadly this is of no avail.  For php 5.2 doctrine has a free() method on
several of its classes which breaks the circular references, allowing the
garbage collector to clean things up in that environment.  Allegedly this
isn't needed in 5.3 due to the link you've shared, however, I'm using the
free() call on the $newRecord variable just for grins in a 5.3 environment.

I'm also calling gc_collect_cycles() to try and force a gc, however that
seems to have no effect.

Guess what the folks on doctrine irc channel have suggested .. upgrading to
version 2 or a hacky workaround (basically working on smaller units and
letting the script complete for these smaller chunks of input data).
 Rather disappointing if you ask me.

At this point I'm about as disappointed in php as I am doctine, one would
think there's a way to reclaim this memory, but I can't find a way short of
terminating the script :(

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux