On Sat, September 16, 2006 10:35 am, Matthew H. North wrote: >> So you are just visiting the nodes, and not doing anything with >> them? > > We're appending certain fields to put together a total result. Be very very very careful here... If you throw enough strings around, and append things enough different ways, you may confuse PHP's reference counter enough that it can't be CERTAIN that you are done with a string. Use unset() on any string variable you are "done with" especially in tight loops. This MAY be fixed in current PHP -- I just know it was once an issue. > Great idea -- I just completed a degree in computational physics, > which > included courses that involved dumping loads of data and graphing them > using > tools like gnuplot and OpenDx... you'd think I would have thought of > this one > myself (rolling my eyes). I graphed mine with GD and PHP, personally, when I needed this, but there ya go. Before anybody asks for it, it's a total hack inapplicable to anybody else in any real fashion... I wasn't interested in reusable code for a one-off problem. >> Did you close down the DB connection and kill the PEAR objects?... >> >> PHP's garbage collection has had... issues... in the past. > > All of my classes that extend DataObject inherit a common destructor > that > calls the DataObject::free() method, which, supposedly, frees result > resources. I'm not sure what you mean by 'kill the PEAR objects', but > all > references go out of scope or are unset. Forget "go out of scope" as a solution to memory management. For any external resouces, use xyz_close() on them. For any PHP variables, use unset() This is not C. It's not even Lisp. :-) The definition of "scope" in PHP is "simple" This is very very very GOOD for writing simple little scripts when you don't know diddly-squat about programming. It is also, alas, a bit BAD for the compiler when it comes time to categorically state that $x is or isn't out of scope. The PHP Dev Team has made wondrous strides in this area, but if you're triggering PHP saying "I dunno... This may or may not be out of scope" in a tight loop, you're gonna lose RAM. If you can point to a specific simple instance, where it CAN be proven that something is out of scope and it should be cleaned, that's great for a http://bugs.php.net report... More likely, though, you've hit a point where the answer is indeterminate. I *believe* such instances still exist. I'm not the expert, though, just what I heard the experts say a year ago on this topic. >> > 5) By doing unset($GLOBALS[$varname]) and unset($$varname), where >> > $varname >> > is >> > each key of the $GLOBALS array, I am effectively eliminating all >> > remaining >> > references, and all allocated memory should be reclaimed by the >> memory >> > manager (except perhaps for memory associated with function and >> class >> > definitions). >> >> No. >> >> Dangling pointers and references not correctly cleaned up from a >> function are left out in limbo. > > This I find VERY odd. So if I don't unset all references in a > function before > it exits I lose that memory? There is a potential in some "rare and unusual" circumstances where the referencing is "indeterminate" as to whether PHP can just go ahead and free something. Given the indeterminacy (?), PHP has only one viable path. Leave it. Cuz losing RAM beats a segfault every day. :-) > Perfect -- this is exactly what I was trying to get at. I wasn't even > sure > whether I should be totally confident that my assumptions about PHP > internals > were that solid, and therefore, whether I should _really_ be banging > my head > too hard on this. > > Thanks for your detailed response -- you answered my questions and > then some. > > Is there a resource out there that explains PHP internals in detail? Use the source, Luke. :-) There probably are reference books, and some may even be sort of current... Subscribing to PHP Internals, and having up to 90% of a conversation be "over your head" is certainly intructive. At least, it was for me. :-) These days I almost understand 80% of it, though... At least I think I understand 80% of it. Some days you get the bear. Some days the bear gets you. As before: Cranking you limit to 16M may be the Right Answer, no matter how "icky" that feels... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php