Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17792 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81771 invoked by uid 1010); 10 Aug 2005 14:55:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 81756 invoked from network); 10 Aug 2005 14:55:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2005 14:55:29 -0000 X-Host-Fingerprint: 195.225.34.5 unknown Received: from ([195.225.34.5:1800] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id F2/0A-24081-0651AF24 for ; Wed, 10 Aug 2005 10:55:28 -0400 Message-ID: To: internals@lists.php.net References: <21.AF.04646.20AC8F24@pb1.pair.com><5.1.0.14.2.20050809123954.03491eb0@localhost><124244453.20050810114522@marcus-boerger.de> <5.1.0.14.2.20050810070706.042bcec0@localhost> Date: Wed, 10 Aug 2005 16:47:47 +0200 Lines: 80 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 195.225.34.5 Subject: Re: [PHP-DEV] Re: drastic memory consumption with a sequenceofexceptions From: r.korving@xit.nl ("Ron Korving") Thanks, that's all I would ever ask for :) Ron "Andi Gutmans" schreef in bericht news:5.1.0.14.2.20050810070706.042bcec0@localhost... > Hi Ron, > > Indeed exception may lead to leaks in certain cases. We do try and cleanup > as much as possible but the situation you describe is hard to detect. I > will however put it on our TODO list because this case could possibly be > improved on. > > Andi > > At 11:54 AM 8/10/2005 +0200, Ron Korving wrote: > >You're right, using that file to create a big piece of data was just for > >demonstration purposes. In my personal case it's XML parsing. The way I read > >what you just said is that this is behavior by design. But if I don't throw > >Exceptions, memory usage stays constant. Throwing and catching these > >exceptions are the exception-to-the-rule. > > > >Nonetheless, if this is truly by design.. maybe that's something to look > >into for PHP6. > > > >Ron > > > >"Marcus Boerger" schreef in bericht > >news:124244453.20050810114522@marcus-boerger.de... > > > Hello Ron, > > > > > > Wednesday, August 10, 2005, 8:47:25 AM, you wrote: > > > > > > > Okay Andi, the script in this message is as simple as it gets. I used a > > > > syslog file to create a load of data in this case, but of course you can > >use > > > > any (text) file for this. > > > > > > > #!/usr/bin/php5 > > > > > > > function process() > > > > { > > > > $data = file("/var/log/syslog.0"); > > > > > > > foreach ($data as $line) > > > > throw new Exception("error"); > > > > > > What makes you think the file would be closed. Erm the array deleted? And > > > that is your problem you are unnecessarily reading all the file into an > > > array. Try using the same with FileObject instead, which should reduce > > > memory usage a lot: > > > > > > foreach(FileObject($file) as $data) throw new Exception("error"); > > > > > > But of course you only did that to demonstrate the memory problem which in > > > fact simply means that we don't do a full stack cleanup like c++ would do > > > here (php != c++). > > > > > > In php we do the cleanup at script termination. That is also the reason > > > why php is not perfectly suitable for console apps especially when it > >comes > > > to daemons. > > > > > > best regards > > > marcus > > > >-- > >PHP Internals - PHP Runtime Development Mailing List > >To unsubscribe, visit: http://www.php.net/unsub.php