Re: Re: drastic memory consumption with a sequenceof exceptions

From: Date: Wed, 10 Aug 2005 12:38:30 +0000
Subject: Re: Re: drastic memory consumption with a sequenceof exceptions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-17779@lists.php.net to get a copy of this message
Perhaps it would require an revised garbage collection mechanism? If that's the case and you think it's worth investing time in, I think it would be something for the next major version (6). Good luck, Ron ""Dmitry Stogov"" <dmitry@zend.com> schreef in bericht news:000001c59da7$96c4b420$e902a8c0@thinkpad... > I have opened the bug #34065, but it is very hard to fix it. > > Thanks. Dmitry. > > > -----Original Message----- > > From: Ron Korving [mailto:r.korving@xit.nl] > > Sent: Wednesday, August 10, 2005 1:55 PM > > To: internals@lists.php.net > > Subject: Re: [PHP-DEV] Re: drastic memory consumption with a > > sequenceof exceptions > > > > > > 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" <helly@php.net> 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 > > > >

« previous php.internals (#17779) next »