On Mon, Jun 20, 2011 at 5:16 AM, Ford, Mike <M.Ford@xxxxxxxxxxxxxx> wrote: > > -----Original Message----- > > From: Nathan Nobbe [mailto:quickshiftin@xxxxxxxxx] > > Sent: 16 June 2011 17:51 > > [...] > > > 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 know nothing about Doctrine, but after all the unrelated > discussion and your renewed plea for someone to address the issue, > I decided to write conduct some simple tests. > > So I wrote a very simple class that basically just hogs some memory > when instantiated, and tried some simple instantiations and > releases. > > At each stage, I measured current and peak memory usage, and the > results were: > > Initial > Usage = 262,144 > Peak = 262,144 > > After single instantiation ($a = new Hog();) > Usage = 3,932,160 > Peak = 3,932,160 > > After resetting that to NULL ($a = NULL;) > Usage = 524,288 > Peak = 3,932,160 > > After second single instantiation ($b = new Hog();) > Usage = 3,932,160 > Peak = 3,932,160 > > After instantiating 3 more > Usage = 15,728,640 > Peak = 15,728,640 > > After resetting all those to NULL > Usage = 1,310,720 > Peak = 15,728,640 > > After 4 instantiations again > Usage = 15,728,640 > Peak = 15,728,640 > > This seems to be pretty much what I (and you!) would expect, > indicating that the memory used by objects can be recovered by PHP > when the object is released. This being the case, I would suggest > that something in your script is not freeing things up the way it > should, the prime candidate being the clearRelated() method. Either > that, or you have circular references that the gc_collect_cycles() > function is unable to recover. But, bottom line, I'd say you're > right that it's probably a Doctrine-related issue as the underlying > PHP functionality seems to work reasonably well. > Mike, thanks for your time here. I have been able to develop a workaround and it actually does run fast enough to work for now. Actually, I'd love to pin down the issue w/ Doctrine, I just have a lot of clients right now and can't justify the time, so the hacky solution will have to suffice. I did just find a bug in PHPUnit about a week ago, but that was easy to isolate. In order to isolate the issue with Doctrine it will take me a few hours. So even though today is a rainy one, I won't be able to work on it because I have too much other stuff going on that actually pays the bills, lol. -nathan